[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/2] scsi: mptconfig: fix an assert expression
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 2/2] scsi: mptconfig: fix an assert expression |
Date: |
Thu, 1 Sep 2016 13:16:01 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
On 31/08/2016 14:06, P J P wrote:
> diff --git a/hw/scsi/mptconfig.c b/hw/scsi/mptconfig.c
> index 1ec895b..531947f 100644
> --- a/hw/scsi/mptconfig.c
> +++ b/hw/scsi/mptconfig.c
> @@ -158,7 +158,7 @@ static size_t mptsas_config_pack(uint8_t **data, const
> char *fmt, ...)
> va_end(ap);
>
> if (data) {
> - assert(ret < 256 && (ret % 4) == 0);
> + assert(ret / 4 < 256);
> stb_p(*data + 1, ret / 4);
> }
> return ret;
>
The (ret % 4) == 0 part is still useful. Here is the patch I'm
committing with a commit message that explains the change:
commit f7a080e249008fdb90b070dff15d45690b6a06b8
Author: Prasad J Pandit <address@hidden>
Date: Wed Aug 31 17:36:07 2016 +0530
scsi: mptconfig: fix an assert expression
When LSI SAS1068 Host Bus emulator builds configuration page
headers, mptsas_config_pack() should assert that the size
fits in a byte. However, the size is expressed in 32-bit
units, so up to 1020 bytes fit. The assertion was only
allowing replies up to 252 bytes, so fix it.
Suggested-by: Paolo Bonzini <address@hidden>
Signed-off-by: Prasad J Pandit <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
diff --git a/hw/scsi/mptconfig.c b/hw/scsi/mptconfig.c
index 7071854..3e4f400 100644
--- a/hw/scsi/mptconfig.c
+++ b/hw/scsi/mptconfig.c
@@ -158,7 +158,7 @@ static size_t mptsas_config_pack(uint8_t **data, const char
*fmt, ...)
va_end(ap);
if (data) {
- assert(ret < 256 && (ret % 4) == 0);
+ assert(ret / 4 < 256 && (ret % 4) == 0);
stb_p(*data + 1, ret / 4);
}
return ret;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-devel] [PATCH 2/2] scsi: mptconfig: fix an assert expression,
Paolo Bonzini <=