Skip to content

Commit f07296b

Browse files
niharcygregkh
authored andcommitted
staging: gpib: cec: Handle gpib_register_driver() errors
The function gpib_register_driver() can fail and result in a semi-registered module and does not return an error value if it fails. Unregister the pci registering function in case gpib_register_driver() fails and return the error value. Add pr_err() statements indicating the fail and also the error value. Signed-off-by: Nihar Chaithanya <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 65aff9b commit f07296b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/staging/gpib/cec/cec_gpib.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,15 @@ static int __init cec_init_module(void)
365365

366366
result = pci_register_driver(&cec_pci_driver);
367367
if (result) {
368-
pr_err("cec_gpib: pci_driver_register failed!\n");
368+
pr_err("cec_gpib: pci_register_driver failed: error = %d\n", result);
369369
return result;
370370
}
371371

372-
gpib_register_driver(&cec_pci_interface, THIS_MODULE);
372+
result = gpib_register_driver(&cec_pci_interface, THIS_MODULE);
373+
if (result) {
374+
pr_err("cec_gpib: gpib_register_driver failed: error = %d\n", result);
375+
return result;
376+
}
373377

374378
return 0;
375379
}

0 commit comments

Comments
 (0)