Received: from eggs.gnu.org ([2001:4830:134:3::10]:54531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjQb5-0001jb-Md for qemu-devel@nongnu.org; Mon, 12 Sep 2016 08:44:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjQaz-0006mr-Qe for qemu-devel@nongnu.org; Mon, 12 Sep 2016 08:44:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48662) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjQaz-0006m8-L8 for qemu-devel@nongnu.org; Mon, 12 Sep 2016 08:44:21 -0400 From: P J P Date: Mon, 12 Sep 2016 18:14:11 +0530 Message-Id: <1473684251-17476-1-git-send-email-ppandit@redhat.com> Subject: [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: Qemu Developers Cc: Paolo Bonzini , Li Qiang 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 --- 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; -- 2.5.5