[PATCH 4/5] pmcraid: check for exceeding the max adapters limit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add proper check for running out of bitmap slot and disallow exceeding
the max adapters limit.

Signed-off-by: Akinobu Mita <akinobu.mita@xxxxxxxxx>
Cc: Anil Ravindranath <anil_ravindranath@xxxxxxxxxxxxxx>
Cc: "James E.J. Bottomley" <JBottomley@xxxxxxxxxxxxx>
Cc: linux-scsi@xxxxxxxxxxxxxxx
---
 drivers/scsi/pmcraid.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 583ec82..e3b68d9 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -5372,8 +5372,10 @@ static unsigned short pmcraid_get_minor(void)
 {
 	int minor;
 
-	minor = find_first_zero_bit(pmcraid_minor, sizeof(pmcraid_minor));
-	__set_bit(minor, pmcraid_minor);
+	minor = find_first_zero_bit(pmcraid_minor, PMCRAID_MAX_ADAPTERS);
+	if (minor < PMCRAID_MAX_ADAPTERS)
+		__set_bit(minor, pmcraid_minor);
+
 	return minor;
 }
 
@@ -5399,6 +5401,9 @@ static int pmcraid_setup_chrdev(struct pmcraid_instance *pinstance)
 	int error;
 
 	minor = pmcraid_get_minor();
+	if (minor >= PMCRAID_MAX_ADAPTERS)
+		return -EBUSY;
+
 	cdev_init(&pinstance->cdev, &pmcraid_fops);
 	pinstance->cdev.owner = THIS_MODULE;
 
-- 
1.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux