Skip to content

Commit e999bd2

Browse files
niharcygregkh
authored andcommitted
staging: gpib: Modify gpib_register_driver() to return error if it fails
The function gpib_register_driver() can fail if kmalloc() fails, but it doesn't return any error if that happens. Modify the function to return error i.e int. Return the appropriate error code if it fails. Remove the pr_info() statement. 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 33bd646 commit e999bd2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/staging/gpib/common/gpib_os.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,18 +2094,19 @@ void init_gpib_descriptor(gpib_descriptor_t *desc)
20942094
atomic_set(&desc->io_in_progress, 0);
20952095
}
20962096

2097-
void gpib_register_driver(gpib_interface_t *interface, struct module *provider_module)
2097+
int gpib_register_driver(gpib_interface_t *interface, struct module *provider_module)
20982098
{
20992099
struct gpib_interface_list_struct *entry;
21002100

21012101
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
21022102
if (!entry)
2103-
return;
2103+
return -ENOMEM;
21042104

21052105
entry->interface = interface;
21062106
entry->module = provider_module;
21072107
list_add(&entry->list, &registered_drivers);
2108-
pr_info("gpib: registered %s interface\n", interface->name);
2108+
2109+
return 0;
21092110
}
21102111
EXPORT_SYMBOL(gpib_register_driver);
21112112

drivers/staging/gpib/include/gpibP.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <linux/fs.h>
1818
#include <linux/interrupt.h>
1919

20-
void gpib_register_driver(gpib_interface_t *interface, struct module *mod);
20+
int gpib_register_driver(gpib_interface_t *interface, struct module *mod);
2121
void gpib_unregister_driver(gpib_interface_t *interface);
2222
struct pci_dev *gpib_pci_get_device(const gpib_board_config_t *config, unsigned int vendor_id,
2323
unsigned int device_id, struct pci_dev *from);

0 commit comments

Comments
 (0)