scsi: mptsas: use g_new0 to allocate MPTSASRequest object
PATCH 1/1 scsi: mptsas: use g_new0 to allocate MPTSASRequest object
From: Li Qiang <[email protected]>
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 <[email protected]>
Signed-off-by Prasad J Pandit <[email protected]>
--- hw/scsi/mptsas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/mptsas.c +1 -1
@@ -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;
Signature · 1 line
2.5.5
Paolo Bonzini
AppliedQuoted 9 lines · P J P
From: Li Qiang <[email protected]>
When processing IO request in mptsas, it uses
g_newto allocate a 'req' object. If an error occurs before 'req->sreq' is allocated, It could lead to an OOB write inmptsas_free_requestfunction. Useg_new0to avoid it.Reported-by Li Qiang <[email protected]>Signed-off-by Prasad J Pandit <[email protected]>
Queued, thanks.
Quoted 18 lines
--- hw/scsi/mptsas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/scsi/mptsas.c +1
-1@@ -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;