All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi_dh: only attach to SCSI devices
@ 2017-02-16  7:33 Hannes Reinecke
  2017-02-16 14:30 ` Bart Van Assche
  2017-02-16 14:32 ` Christoph Hellwig
  0 siblings, 2 replies; 6+ messages in thread
From: Hannes Reinecke @ 2017-02-16  7:33 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, Keith Busch, linux-scsi, Bart van Assche,
	Hannes Reinecke, Hannes Reinecke

Any device might be setting a queuedata structure, so we need to
check if the queuedata really belongs to a SCSI device before
proceeding.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/scsi_dh.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c
index b8d3b97..da104ed 100644
--- a/drivers/scsi/scsi_dh.c
+++ b/drivers/scsi/scsi_dh.c
@@ -226,7 +226,9 @@ static struct scsi_device *get_sdev_from_queue(struct request_queue *q)
 
 	spin_lock_irqsave(q->queue_lock, flags);
 	sdev = q->queuedata;
-	if (!sdev || !get_device(&sdev->sdev_gendev))
+	if (!sdev ||
+	    !scsi_is_sdev_device(&sdev->sdev_gendev) ||
+	    !get_device(&sdev->sdev_gendev))
 		sdev = NULL;
 	spin_unlock_irqrestore(q->queue_lock, flags);
 
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-02-16 14:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-16  7:33 [PATCH] scsi_dh: only attach to SCSI devices Hannes Reinecke
2017-02-16 14:30 ` Bart Van Assche
2017-02-16 14:38   ` hch
2017-02-16 14:38     ` Hannes Reinecke
2017-02-16 14:32 ` Christoph Hellwig
2017-02-16 14:35   ` Bart Van Assche

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.