From 605c6dbef7556604b20b9831ea790dfe988416d8 Mon Sep 17 00:00:00 2001 From: Mark Knibbs Date: Thu, 9 Oct 2014 12:39:48 +0100 Subject: [PATCH] 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: Mark Knibbs Reviewed-by: Martin K. Petersen Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 619e68d015aa..b1aa1646012a 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -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)) || ((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; mutex_lock(&shost->scan_mutex);