From: Bart Van Assche Date: Fri, 25 Aug 2017 20:46:40 +0000 (-0700) Subject: scsi: scsi_transport_sas: Check kzalloc() return value X-Git-Tag: v4.14-rc1~41^2~61 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1779b4ff5412fcb7f943f6b49cac5e70fc724e2;p=platform%2Fkernel%2Flinux-rpi.git scsi: scsi_transport_sas: Check kzalloc() return value Check whether memory allocation succeeded before dereferencing the pointer to the allocated memory. Signed-off-by: Bart Van Assche Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Cc: Johannes Thumshirn Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index 5006a65..e2e948f 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c @@ -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;