Skip to contentSkip to conversation

scsi: Avoid crashing if device uses DIX but adapter does not support it

PATCH In review Ewan D. Milne 2 participants 2 messages Jan 15, 2015 – Jan 20, 2015 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scsi: Avoid crashing if device uses DIX but adapter does not support it

From: "Ewan D. Milne" <[email protected]>

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.

---
 drivers/scsi/scsi_lib.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +11 -1
index 6d5c0b8..17bb541 100644
@@ -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)) {
Signature · 1 line
1.7.11.7
Reviewed-by on v2 1/1
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Ewan" == Ewan D Milne <[email protected]> writes:

Ewan> This can happen if a multipathed device uses DIX and another path Ewan> is added via an adapter that does not support it. Multipath Ewan> should not allow this path to be added, but we should not depend Ewan> upon that to avoid crashing.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering