Skip to content

Commit

Permalink
scsi: Avoid crashing if device uses DIX but adapter does not support it
Browse files Browse the repository at this point in the history
This can happen if a multipathed device uses DIX and another path is
added via an adapter that does not support it.  Multipath should not
allow this path to be added, but we should not depend upon that to avoid
crashing.

Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Ewan D. Milne authored and Christoph Hellwig committed Jan 20, 2015
1 parent 99531e6 commit 91724c2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/scsi/scsi_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,17 @@ int scsi_init_io(struct scsi_cmnd *cmd)
struct scsi_data_buffer *prot_sdb = cmd->prot_sdb;
int ivecs, count;

BUG_ON(prot_sdb == NULL);
if (prot_sdb == NULL) {
/*
* This can happen if someone (e.g. multipath)
* queues a command to a device on an adapter
* that does not support DIX.
*/
WARN_ON_ONCE(1);
error = BLKPREP_KILL;
goto err_exit;
}

ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio);

if (scsi_alloc_sgtable(prot_sdb, ivecs, is_mq)) {
Expand Down

0 comments on commit 91724c2

Please sign in to comment.