Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 249cec18 authored by Colin Ian King's avatar Colin Ian King Committed by Greg Kroah-Hartman
Browse files

usb: storage: return on error to avoid a null pointer dereference



commit 446230f52a5bef593554510302465eabab45a372 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: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e19d1c64
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -1522,8 +1522,11 @@ static void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us)


	/* Make sure driver was initialized */
	/* Make sure driver was initialized */


	if (us->extra == NULL)
	if (us->extra == NULL) {
		usb_stor_dbg(us, "ERROR Driver not initialized\n");
		usb_stor_dbg(us, "ERROR Driver not initialized\n");
		srb->result = DID_ERROR << 16;
		return;
	}


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