Re: [PATCH 16/19] scsi_transport_sas, sas_tlr_supported(): Check kzalloc() return value

Hannes Reinecke
2017-08-25T15:52:58Z

On 08/23/2017 11:40 PM, Bart Van Assche wrote:
> Check whether memory allocation succeeded before dereferencing
> the pointer to the allocated memory.
>
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Johannes Thumshirn <jthumshirn@suse.de>
> ---
> drivers/scsi/scsi_transport_sas.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
> index a318c46db7cc..1a0fa79fd49a 100644
> --- a/drivers/scsi/scsi_transport_sas.c
> +++ b/drivers/scsi/scsi_transport_sas.c
> @@ -423,6 +423,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;
>
>
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)