Skip to content

Commit

Permalink
SCSI: Fix error handling when no ULD is attached
Browse files Browse the repository at this point in the history
Commit 18a4d0a ("[SCSI] Handle disk devices which can not process
medium access commands") introduced a bug in which we would attempt to
dereference the scsi driver even when the device had no ULD attached.

Ensure that a driver is registered and make the driver accessor function
more resilient to errors during device discovery.

Reported-by: Elric Fu <[email protected]>
Reported-by: Bart Van Assche <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
martinkpetersen authored and torvalds committed Apr 15, 2012
1 parent bfecc60 commit 919f797
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/scsi/scsi_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,

scsi_eh_restore_cmnd(scmd, &ses);

if (sdrv->eh_action)
if (sdrv && sdrv->eh_action)
rtn = sdrv->eh_action(scmd, cmnd, cmnd_size, rtn);

return rtn;
Expand Down
3 changes: 3 additions & 0 deletions include/scsi/scsi_cmnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ struct scsi_cmnd {

static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
{
if (!cmd->request->rq_disk)
return NULL;

return *(struct scsi_driver **)cmd->request->rq_disk->private_data;
}

Expand Down

0 comments on commit 919f797

Please sign in to comment.