scsi: fix potential NULL pointer dereference.
PATCH 1/1 scsi: fix potential NULL pointer dereference.
The scsi_get_command() function returns NULL if it fails to allocate the scsi_cmnd structure. If this happens, a NULL pointer will be dereferenced.
--- drivers/scsi/scsi_error.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/scsi_error.c +3 -0
@@ -2289,6 +2289,9 @@ scsi_reset_provider(struct scsi_device *dev, int flag)return FAILED ; scmd =scsi_get_command (dev,GFP_KERNEL ); +if (!scmd) +return FAILED ; +blk_rq_init (NULL , &req); scmd->request = &req;
Signature · 1 line
Maurizio Lombardi
drivers/scsi/scsi_error.c scsi_reset_provider(struct scsi_device *dev, int flag) · line 2294
Quoted 11 lines
drivers/scsi/scsi_error.c +3
-0@@ -2289,6 +2289,9 @@ scsi_reset_provider(struct scsi_device *dev, int flag)return FAILED ; scmd =scsi_get_command (dev,GFP_KERNEL ); +if (!scmd) +return FAILED ; +
Fails to call scsi_autopm_put_host, or in Jame's latest tree that has my changes put_device on the sdev gendev. I sent a correct version earlier, but there has been very little enthusiasm for it.
Quoted 7 lines · Christoph Hellwig
Quoted 7 lines
drivers/scsi/scsi_error.c +0
-0@@ -2289,6 +2289,9 @@ scsi_reset_provider(struct scsi_device *dev, int flag)return FAILED ;
Quoted 9 lines
drivers/scsi/scsi_error.c scsi_reset_provider(struct scsi_device *dev, int flag) · line 2294
Quoted 4 lines
drivers/scsi/scsi_error.c +3
-0scmd =scsi_get_command (dev,GFP_KERNEL ); +if (!scmd) +return FAILED ; +Fails to call
scsi_autopm_put_host, or in Jame's latest tree that has my changesput_deviceon the sdev gendev. I sent a correct version earlier, but there has been very little enthusiasm for it.
Yes you are right, it should call scsi_autopm_put_host before returning. So if you already have a correct version for it then I drop this patch.
Maurizio.
Quoted 2 lines · Maurizio Lombardi
Yes you are right, it should call
scsi_autopm_put_hostbefore returning. So if you already have a correct version for it then I drop this patch.
This was the version I sent out:
http://git.infradead.org/users/hch/scsi.git/commitdiff/245e16e9091f92919c09c8bbae1d982d0717ba22
It's not correct for Jame's current tree as we also need to unwind getting a reference on sdev_gendev now. As there's been pushback against the patch I didn't resubmit it yet, but now that I got my other changes in the area in it might be worth to try again.