Received: from eggs.gnu.org ([2001:4830:134:3::10]:56444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfPyi-0004E8-3R for qemu-devel@nongnu.org; Thu, 01 Sep 2016 07:16:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bfPyd-0008C6-Rj for qemu-devel@nongnu.org; Thu, 01 Sep 2016 07:16:14 -0400 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:35326) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfPyd-0008Bn-J6 for qemu-devel@nongnu.org; Thu, 01 Sep 2016 07:16:11 -0400 Received: by mail-lf0-x244.google.com with SMTP id e7so2709698lfe.2 for ; Thu, 01 Sep 2016 04:16:11 -0700 (PDT) Sender: Paolo Bonzini References: <1472645167-30765-1-git-send-email-ppandit@redhat.com> <1472645167-30765-2-git-send-email-ppandit@redhat.com> From: Paolo Bonzini Message-ID: <5c548a16-1729-d96c-7027-17a22922fa01@redhat.com> Date: Thu, 1 Sep 2016 13:16:01 +0200 MIME-Version: 1.0 In-Reply-To: <1472645167-30765-2-git-send-email-ppandit@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] scsi: mptconfig: fix an assert expression List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: P J P , Qemu Developers Cc: Prasad J Pandit 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 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 Signed-off-by: Prasad J Pandit Message-Id: <1472645167-30765-2-git-send-email-ppandit@redhat.com> Signed-off-by: Paolo Bonzini 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;