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@xxxxxxxxx> Cc: Anil Ravindranath <anil_ravindranath@xxxxxxxxxxxxxx> Cc: "James E.J. Bottomley" <JBottomley@xxxxxxxxxxxxx> Cc: linux-scsi@xxxxxxxxxxxxxxx --- 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 -- 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