Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 605c6dbe authored by Mark Knibbs's avatar Mark Knibbs Committed by Christoph Hellwig
Browse files

scsi: fix off-by-one LUN check in scsi_scan_host_selected()



The Scsi_Host structure max_lun field is the maximum allowed LUN plus 1. So
a LUN value is invalid if >= max_lun.

Signed-off-by: default avatarMark Knibbs <markk@clara.co.uk>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent fb0d82f4
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1727,7 +1727,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,


	if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) ||
	if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) ||
	    ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) ||
	    ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) ||
	    ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun)))
	    ((lun != SCAN_WILD_CARD) && (lun >= shost->max_lun)))
		return -EINVAL;
		return -EINVAL;


	mutex_lock(&shost->scan_mutex);
	mutex_lock(&shost->scan_mutex);