* [PATCH 1/5] pmcraid: fix a typo in error message
@ 2013-02-16 14:27 Akinobu Mita
2013-02-16 14:27 ` [PATCH 2/5] pmcraid: fix pmcraid_netlink_init() error path in module_init Akinobu Mita
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Akinobu Mita @ 2013-02-16 14:27 UTC (permalink / raw)
To: linux-scsi; +Cc: Akinobu Mita, Anil Ravindranath, James E.J. Bottomley
Remove duplicate "with" in error message.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Anil Ravindranath <anil_ravindranath@pmc-sierra.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/pmcraid.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index b46f5e9..073ff48 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -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;
}
--
1.8.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/5] pmcraid: fix pmcraid_netlink_init() error path in module_init
2013-02-16 14:27 [PATCH 1/5] pmcraid: fix a typo in error message Akinobu Mita
@ 2013-02-16 14:27 ` Akinobu Mita
2013-02-16 14:27 ` [PATCH 3/5] pmcraid: make pmcraid_minor static Akinobu Mita
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Akinobu Mita @ 2013-02-16 14:27 UTC (permalink / raw)
To: linux-scsi; +Cc: Akinobu Mita, Anil Ravindranath, James E.J. Bottomley
pmcraid_netlink_init() error path in module_init doesn't destroy
a struct class that was created just before.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Anil Ravindranath <anil_ravindranath@pmc-sierra.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/pmcraid.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 073ff48..db77bf9 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -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);
--
1.8.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/5] pmcraid: make pmcraid_minor static
2013-02-16 14:27 [PATCH 1/5] pmcraid: fix a typo in error message Akinobu Mita
2013-02-16 14:27 ` [PATCH 2/5] pmcraid: fix pmcraid_netlink_init() error path in module_init Akinobu Mita
@ 2013-02-16 14:27 ` Akinobu Mita
2013-02-16 14:27 ` [PATCH 4/5] pmcraid: check for exceeding the max adapters limit Akinobu Mita
2013-02-16 14:27 ` [PATCH 5/5] pmcraid: check error from device_create() Akinobu Mita
3 siblings, 0 replies; 5+ messages in thread
From: Akinobu Mita @ 2013-02-16 14:27 UTC (permalink / raw)
To: linux-scsi; +Cc: Akinobu Mita, Anil Ravindranath, James E.J. Bottomley
The bitmap pmcraid_minor is only used in this file.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Anil Ravindranath <anil_ravindranath@pmc-sierra.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/pmcraid.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index db77bf9..583ec82 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -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
--
1.8.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/5] pmcraid: check for exceeding the max adapters limit
2013-02-16 14:27 [PATCH 1/5] pmcraid: fix a typo in error message Akinobu Mita
2013-02-16 14:27 ` [PATCH 2/5] pmcraid: fix pmcraid_netlink_init() error path in module_init Akinobu Mita
2013-02-16 14:27 ` [PATCH 3/5] pmcraid: make pmcraid_minor static Akinobu Mita
@ 2013-02-16 14:27 ` Akinobu Mita
2013-02-16 14:27 ` [PATCH 5/5] pmcraid: check error from device_create() Akinobu Mita
3 siblings, 0 replies; 5+ messages in thread
From: Akinobu Mita @ 2013-02-16 14:27 UTC (permalink / raw)
To: linux-scsi; +Cc: Akinobu Mita, Anil Ravindranath, James E.J. Bottomley
Add proper check for running out of bitmap slot and disallow exceeding
the max adapters limit.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Anil Ravindranath <anil_ravindranath@pmc-sierra.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5/5] pmcraid: check error from device_create()
2013-02-16 14:27 [PATCH 1/5] pmcraid: fix a typo in error message Akinobu Mita
` (2 preceding siblings ...)
2013-02-16 14:27 ` [PATCH 4/5] pmcraid: check for exceeding the max adapters limit Akinobu Mita
@ 2013-02-16 14:27 ` Akinobu Mita
3 siblings, 0 replies; 5+ messages in thread
From: Akinobu Mita @ 2013-02-16 14:27 UTC (permalink / raw)
To: linux-scsi; +Cc: Akinobu Mita, Anil Ravindranath, James E.J. Bottomley
Fix an unchecked error from device_create() and convert to use standard
goto based unwinding for error cleanup.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Anil Ravindranath <anil_ravindranath@pmc-sierra.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/pmcraid.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index e3b68d9..d3034a8 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -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;
}
--
1.8.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-02-16 14:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-16 14:27 [PATCH 1/5] pmcraid: fix a typo in error message Akinobu Mita
2013-02-16 14:27 ` [PATCH 2/5] pmcraid: fix pmcraid_netlink_init() error path in module_init Akinobu Mita
2013-02-16 14:27 ` [PATCH 3/5] pmcraid: make pmcraid_minor static Akinobu Mita
2013-02-16 14:27 ` [PATCH 4/5] pmcraid: check for exceeding the max adapters limit Akinobu Mita
2013-02-16 14:27 ` [PATCH 5/5] pmcraid: check error from device_create() Akinobu Mita
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.