summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEwan D. Milne <emilne@redhat.com>2015-01-15 18:02:12 +0300
committerJiri Slaby <jslaby@suse.cz>2016-05-03 18:42:13 +0300
commitafa099d3a6ef1aef855cbda0a03536617d0287a1 (patch)
tree2afcb02e5d018569cb30678f0565494a0b3960c5
parentd9a229158da32c2a45129362c85b3c9eb3c64bcc (diff)
downloadlinux-afa099d3a6ef1aef855cbda0a03536617d0287a1.tar.xz
scsi: Avoid crashing if device uses DIX but adapter does not support it
commit 91724c20613484555ba7e7b3d8549dac1e24f7a8 upstream. 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> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
-rw-r--r--drivers/scsi/scsi_lib.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 0c6a2660d1d5..2b01c88ad416 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1096,7 +1096,17 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask)
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, gfp_mask)) {