summaryrefslogtreecommitdiffstats
path: root/drivers/staging/xillybus/xillybus_core.c
diff options
context:
space:
mode:
authorEli Billauer2014-09-04 16:47:46 +0200
committerGreg Kroah-Hartman2014-09-08 22:58:19 +0200
commit5b09fc96476d7171fdffd5f5cd53da10685fc8e1 (patch)
treea67b3d6d4cddfac38d3f9fd975d3d07122e97808 /drivers/staging/xillybus/xillybus_core.c
parentstaging: xillybus: Improved error handling (diff)
downloadkernel-qcow2-linux-5b09fc96476d7171fdffd5f5cd53da10685fc8e1.tar.gz
kernel-qcow2-linux-5b09fc96476d7171fdffd5f5cd53da10685fc8e1.tar.xz
kernel-qcow2-linux-5b09fc96476d7171fdffd5f5cd53da10685fc8e1.zip
staging: xillybus: Improved goto flow for error handling
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Eli Billauer <eli.billauer@gmail.com> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/xillybus/xillybus_core.c')
-rw-r--r--drivers/staging/xillybus/xillybus_core.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/staging/xillybus/xillybus_core.c b/drivers/staging/xillybus/xillybus_core.c
index fc14b143d413..45dbf07ec7de 100644
--- a/drivers/staging/xillybus/xillybus_core.c
+++ b/drivers/staging/xillybus/xillybus_core.c
@@ -1837,7 +1837,7 @@ static int xillybus_init_chrdev(struct xilly_endpoint *endpoint,
if (rc) {
dev_warn(endpoint->dev, "Failed to obtain major/minors");
- goto error1;
+ return rc;
}
endpoint->major = major = MAJOR(dev);
@@ -1849,7 +1849,7 @@ static int xillybus_init_chrdev(struct xilly_endpoint *endpoint,
endpoint->num_channels);
if (rc) {
dev_warn(endpoint->dev, "Failed to add cdev. Aborting.\n");
- goto error2;
+ goto unregister_chrdev;
}
idt++;
@@ -1874,7 +1874,8 @@ static int xillybus_init_chrdev(struct xilly_endpoint *endpoint,
dev_warn(endpoint->dev,
"Failed to create %s device. Aborting.\n",
devname);
- goto error3;
+ rc = -ENODEV;
+ goto unroll_device_create;
}
}
@@ -1882,15 +1883,14 @@ static int xillybus_init_chrdev(struct xilly_endpoint *endpoint,
endpoint->num_channels);
return 0; /* succeed */
-error3:
+unroll_device_create:
devnum--; i--;
for (; devnum >= 0; devnum--, i--)
device_destroy(xillybus_class, MKDEV(major, i));
cdev_del(&endpoint->cdev);
-error2:
+unregister_chrdev:
unregister_chrdev_region(MKDEV(major, minor), endpoint->num_channels);
-error1:
return rc;
}