summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2017-07-06 18:06:32 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-07-17 14:11:57 +0300
commit446230f52a5bef593554510302465eabab45a372 (patch)
tree77ae0ac884bb89ddb91c43d44808b4af44f4e4f4 /drivers/usb
parent86be7f7b2d940ddc18143061e77989b017d93bf8 (diff)
downloadlinux-446230f52a5bef593554510302465eabab45a372.tar.xz
usb: storage: return on error to avoid a null pointer dereference
When us->extra is null the driver is not initialized, however, a later call to osd200_scsi_to_ata is made that dereferences us->extra, causing a null pointer dereference. The code currently detects and reports that the driver is not initialized; add a return to avoid the subsequent dereference issue in this check. Thanks to Alan Stern for pointing out that srb->result needs setting to DID_ERROR << 16 Detected by CoverityScan, CID#100308 ("Dereference after null check") Signed-off-by: Colin Ian King <colin.king@canonical.com> Cc: stable <stable@vger.kernel.org> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/storage/isd200.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index fba4005dd737..6a7720e66595 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -1529,8 +1529,11 @@ static void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us)
/* Make sure driver was initialized */
- if (us->extra == NULL)
+ if (us->extra == NULL) {
usb_stor_dbg(us, "ERROR Driver not initialized\n");
+ srb->result = DID_ERROR << 16;
+ return;
+ }
scsi_set_resid(srb, 0);
/* scsi_bufflen might change in protocol translation to ata */