]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
scsi: scsi_transport_sas: Check kzalloc() return value
authorBart Van Assche <bart.vanassche@wdc.com>
Fri, 25 Aug 2017 20:46:40 +0000 (13:46 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 25 Aug 2017 21:08:08 +0000 (17:08 -0400)
Check whether memory allocation succeeded before dereferencing
the pointer to the allocated memory.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_transport_sas.c

index 5006a656e16a775b055d0c94b8809577ee34fcb3..e2e948f1ce28e09254a57758a3c6cd31aff5bb35 100644 (file)
@@ -421,6 +421,9 @@ sas_tlr_supported(struct scsi_device *sdev)
        char *buffer = kzalloc(vpd_len, GFP_KERNEL);
        int ret = 0;
 
+       if (!buffer)
+               goto out;
+
        if (scsi_get_vpd_page(sdev, 0x90, buffer, vpd_len))
                goto out;