Blame 0008-scsi-mptsas-use-g_new0-to-allocate-MPTSASRequest-obj.patch

3a13dd
From: Li Qiang <liqiang6-s@360.cn>
3a13dd
Date: Mon, 12 Sep 2016 18:14:11 +0530
3a13dd
Subject: [PATCH] scsi: mptsas: use g_new0 to allocate MPTSASRequest object
3a13dd
3a13dd
When processing IO request in mptsas, it uses g_new to allocate
3a13dd
a 'req' object. If an error occurs before 'req->sreq' is
3a13dd
allocated, It could lead to an OOB write in mptsas_free_request
3a13dd
function. Use g_new0 to avoid it.
3a13dd
3a13dd
Reported-by: Li Qiang <liqiang6-s@360.cn>
3a13dd
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
3a13dd
Message-Id: <1473684251-17476-1-git-send-email-ppandit@redhat.com>
3a13dd
Cc: qemu-stable@nongnu.org
3a13dd
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
3a13dd
(cherry picked from commit 670e56d3ed2918b3861d9216f2c0540d9e9ae0d5)
3a13dd
---
3a13dd
 hw/scsi/mptsas.c | 2 +-
3a13dd
 1 file changed, 1 insertion(+), 1 deletion(-)
3a13dd
3a13dd
diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
3a13dd
index 0e0a22f..eaae1bb 100644
3a13dd
--- a/hw/scsi/mptsas.c
3a13dd
+++ b/hw/scsi/mptsas.c
3a13dd
@@ -304,7 +304,7 @@ static int mptsas_process_scsi_io_request(MPTSASState *s,
3a13dd
         goto bad;
3a13dd
     }
3a13dd
 
3a13dd
-    req = g_new(MPTSASRequest, 1);
3a13dd
+    req = g_new0(MPTSASRequest, 1);
3a13dd
     QTAILQ_INSERT_TAIL(&s->pending, req, next);
3a13dd
     req->scsi_io = *scsi_io;
3a13dd
     req->dev = s;