diff options
author | Alexey Khoroshilov <khoroshilov@ispras.ru> | 2014-03-09 01:01:34 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-03-09 10:44:35 +0400 |
commit | 0669e5fa802fb7de3c842388059a777afac13205 (patch) | |
tree | 5766edd79ce18dcdd04fbd99b2bb7acddb4fe3bf | |
parent | af07daa0af2099d7144bb55cbb9d4758d8578a23 (diff) | |
download | linux-0669e5fa802fb7de3c842388059a777afac13205.tar.xz |
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: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/dgap/dgap.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index ad5afbc1e694..bfafe7e3763a 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -547,6 +547,7 @@ static int dgap_start(void) { int rc = 0; unsigned long flags; + struct device *device; /* * make sure that the globals are @@ -570,9 +571,18 @@ static int dgap_start(void) return rc; 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), NULL, "dgap_mgmt"); + if (IS_ERR(device)) { + rc = PTR_ERR(device); + goto failed_device; + } /* Start the poller */ DGAP_LOCK(dgap_poll_lock, flags); @@ -588,6 +598,12 @@ static int dgap_start(void) dgap_driver_state = DRIVER_NEED_CONFIG_LOAD; return rc; + +failed_device: + class_destroy(dgap_class); +failed_class: + unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); + return rc; } /* |