Received: from eggs.gnu.org ([2001:4830:134:3::10]:60515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjQpy-0000di-Gg for qemu-devel@nongnu.org; Mon, 12 Sep 2016 08:59:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjQpx-0005pr-KB for qemu-devel@nongnu.org; Mon, 12 Sep 2016 08:59:50 -0400 Sender: Paolo Bonzini References: <1473684251-17476-1-git-send-email-ppandit@redhat.com> From: Paolo Bonzini Message-ID: <6ab301ed-317d-c968-421b-3377af10719e@redhat.com> Date: Mon, 12 Sep 2016 14:58:26 +0200 MIME-Version: 1.0 In-Reply-To: <1473684251-17476-1-git-send-email-ppandit@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] scsi: mptsas: use g_new0 to allocate MPTSASRequest object List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: P J P , Qemu Developers Cc: Li Qiang , qemu-stable@nongnu.org On 12/09/2016 14:44, P J P wrote: > From: Li Qiang > > When processing IO request in mptsas, it uses g_new to allocate > a 'req' object. If an error occurs before 'req->sreq' is > allocated, It could lead to an OOB write in mptsas_free_request > function. Use g_new0 to avoid it. > > Reported-by: Li Qiang > Signed-off-by: Prasad J Pandit Cc: qemu-stable@nongnu.org Queued, thanks. > --- > hw/scsi/mptsas.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c > index bebe513..7b02130 100644 > --- a/hw/scsi/mptsas.c > +++ b/hw/scsi/mptsas.c > @@ -304,7 +304,7 @@ static int mptsas_process_scsi_io_request(MPTSASState *s, > goto bad; > } > > - req = g_new(MPTSASRequest, 1); > + req = g_new0(MPTSASRequest, 1); > QTAILQ_INSERT_TAIL(&s->pending, req, next); > req->scsi_io = *scsi_io; > req->dev = s; >