scsi: mptsas: use g_new0 to allocate MPTSASRequest object
authorLi Qiang <liqiang6-s@360.cn>
Mon, 12 Sep 2016 12:44:11 +0000 (18:14 +0530)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 14 Sep 2016 10:25:13 +0000 (12:25 +0200)
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 <liqiang6-s@360.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Message-Id: <1473684251-17476-1-git-send-email-ppandit@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/scsi/mptsas.c

index 0e0a22f6968bb5899c1501c5116dfd60d561f828..eaae1bb182583882704d92005098c40f83769db9 100644 (file)
@@ -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;