Skip to content

Commit ab8e009

Browse files
Colin Ian Kinggregkh
authored andcommitted
usb: storage: return on error to avoid a null pointer dereference
commit 446230f upstream. 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 <[email protected]> Acked-by: Alan Stern <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f883b50 commit ab8e009

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/usb/storage/isd200.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1520,8 +1520,11 @@ static void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us)
15201520

15211521
/* Make sure driver was initialized */
15221522

1523-
if (us->extra == NULL)
1523+
if (us->extra == NULL) {
15241524
usb_stor_dbg(us, "ERROR Driver not initialized\n");
1525+
srb->result = DID_ERROR << 16;
1526+
return;
1527+
}
15251528

15261529
scsi_set_resid(srb, 0);
15271530
/* scsi_bufflen might change in protocol translation to ata */

0 commit comments

Comments
 (0)