Commit 0669e5fa authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Greg Kroah-Hartman

staging: dgap: implement proper error handling in dgap_start()

dgap_start() ignored errors in class_create() and device_create().
The patch implements proper error handling.

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent af07daa0
...@@ -547,6 +547,7 @@ static int dgap_start(void) ...@@ -547,6 +547,7 @@ static int dgap_start(void)
{ {
int rc = 0; int rc = 0;
unsigned long flags; unsigned long flags;
struct device *device;
/* /*
* make sure that the globals are * make sure that the globals are
...@@ -570,9 +571,18 @@ static int dgap_start(void) ...@@ -570,9 +571,18 @@ static int dgap_start(void)
return rc; return rc;
dgap_class = class_create(THIS_MODULE, "dgap_mgmt"); dgap_class = class_create(THIS_MODULE, "dgap_mgmt");
device_create(dgap_class, NULL, if (IS_ERR(dgap_class)) {
rc = PTR_ERR(dgap_class);
goto failed_class;
}
device = device_create(dgap_class, NULL,
MKDEV(DIGI_DGAP_MAJOR, 0), MKDEV(DIGI_DGAP_MAJOR, 0),
NULL, "dgap_mgmt"); NULL, "dgap_mgmt");
if (IS_ERR(device)) {
rc = PTR_ERR(device);
goto failed_device;
}
/* Start the poller */ /* Start the poller */
DGAP_LOCK(dgap_poll_lock, flags); DGAP_LOCK(dgap_poll_lock, flags);
...@@ -588,6 +598,12 @@ static int dgap_start(void) ...@@ -588,6 +598,12 @@ static int dgap_start(void)
dgap_driver_state = DRIVER_NEED_CONFIG_LOAD; dgap_driver_state = DRIVER_NEED_CONFIG_LOAD;
return rc; return rc;
failed_device:
class_destroy(dgap_class);
failed_class:
unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
return rc;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment