Skip to contentSkip to conversation

pmcraid: fix a typo in error message

PATCH New Akinobu Mita 1 participant 5 messages Feb 16, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 pmcraid: fix a typo in error message

Remove duplicate "with" in error message.

Cc Anil Ravindranath <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
---
 drivers/scsi/pmcraid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/pmcraid.c +1 -1
index b46f5e9..073ff48 100644
@@ -6106,7 +6106,7 @@ static int __init pmcraid_init(void)
 
 	if (IS_ERR(pmcraid_class)) {
 		error = PTR_ERR(pmcraid_class);
-		pmcraid_err("failed to register with with sysfs, error = %x\n",
+		pmcraid_err("failed to register with sysfs, error = %x\n",
 			    error);
 		goto out_unreg_chrdev;
 	}
Signature · 1 line
1.8.1
#1 lore raw

PATCH 2/5 pmcraid: fix pmcraid_netlink_init() error path in module_init

pmcraid_netlink_init() error path in module_init doesn't destroy a struct class that was created just before.

Cc Anil Ravindranath <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
---
 drivers/scsi/pmcraid.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/scsi/pmcraid.c +9 -7
index 073ff48..db77bf9 100644
@@ -6114,18 +6114,20 @@ static int __init pmcraid_init(void)
 	error = pmcraid_netlink_init();
 
 	if (error)
-		goto out_unreg_chrdev;
+		goto out_class_destroy;
 
 	error = pci_register_driver(&pmcraid_driver);
 
-	if (error == 0)
-		goto out_init;
+	if (error)
+		goto out_netlink_release;
 
-	pmcraid_err("failed to register pmcraid driver, error = %x\n",
-		     error);
-	class_destroy(pmcraid_class);
-	pmcraid_netlink_release();
+	return 0;
 
+out_netlink_release:
+	pmcraid_err("failed to register pmcraid driver, error = %x\n", error);
+	pmcraid_netlink_release();
+out_class_destroy:
+	class_destroy(pmcraid_class);
 out_unreg_chrdev:
 	unregister_chrdev_region(MKDEV(pmcraid_major, 0), PMCRAID_MAX_ADAPTERS);
 
Signature · 1 line
1.8.1
#2 lore raw

PATCH 3/5 pmcraid: make pmcraid_minor static

In reply to Akinobu Mita

The bitmap pmcraid_minor is only used in this file.

Cc Anil Ravindranath <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
---
 drivers/scsi/pmcraid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/pmcraid.c +1 -1
index db77bf9..583ec82 100644
@@ -76,7 +76,7 @@ static atomic_t pmcraid_adapter_count = ATOMIC_INIT(0);
  */
 static unsigned int pmcraid_major;
 static struct class *pmcraid_class;
-DECLARE_BITMAP(pmcraid_minor, PMCRAID_MAX_ADAPTERS);
+static DECLARE_BITMAP(pmcraid_minor, PMCRAID_MAX_ADAPTERS);
 
 /*
  * Module parameters
Signature · 1 line
1.8.1
#3 lore raw

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

In reply to Akinobu Mita

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

Cc Anil Ravindranath <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
---
 drivers/scsi/pmcraid.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/scsi/pmcraid.c +7 -2
index 583ec82..e3b68d9 100644
@@ -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;
 
Signature · 1 line
1.8.1
#4 lore raw

PATCH 5/5 pmcraid: check error from device_create()

In reply to Akinobu Mita

Fix an unchecked error from device_create() and convert to use standard goto based unwinding for error cleanup.

Cc Anil Ravindranath <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
---
 drivers/scsi/pmcraid.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/scsi/pmcraid.c +16 -4
index e3b68d9..d3034a8 100644
@@ -5399,6 +5399,7 @@ static int pmcraid_setup_chrdev(struct pmcraid_instance *pinstance)
 {
 	int minor;
 	int error;
+	struct device *device;
 
 	minor = pmcraid_get_minor();
 	if (minor >= PMCRAID_MAX_ADAPTERS)
@@ -5408,12 +5409,23 @@ static int pmcraid_setup_chrdev(struct pmcraid_instance *pinstance)
 	pinstance->cdev.owner = THIS_MODULE;
 
 	error = cdev_add(&pinstance->cdev, MKDEV(pmcraid_major, minor), 1);
-
 	if (error)
-		pmcraid_release_minor(minor);
-	else
-		device_create(pmcraid_class, NULL, MKDEV(pmcraid_major, minor),
+		goto out_release_minor;
+
+	device = device_create(pmcraid_class, NULL, MKDEV(pmcraid_major, minor),
 			      NULL, "%s%u", PMCRAID_DEVFILE, minor);
+	if (IS_ERR(device)) {
+		error = PTR_ERR(device);
+		goto out_cdev_del;
+	}
+
+	return 0;
+
+out_cdev_del:
+	cdev_del(&pinstance->cdev);
+out_release_minor:
+	pmcraid_release_minor(minor);
+
 	return error;
 }
 
Signature · 1 line
1.8.1