From b6157a969d43cf929af9cb4aaf283db9519e4c8c Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Wed, 14 Jul 2004 00:47:56 -0700 Subject: [PATCH] [PATCH] USB: usb/core/file.c::usb_major_init() cleanup. This patch does a cleanup for usb/core/file.c::usb_major_init(), which is: *) in error condition, returns the error code from register_chrdev(), insted returning -EBUSY; *) adds missing audit for class_register(); *) only calls devfs_mk_dir() if the prior calls have success. Signed-off-by: Luiz Capitulino Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/file.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 39fdceaf55df0..c74404332978e 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c @@ -79,14 +79,25 @@ static struct class usb_class = { int usb_major_init(void) { - if (register_chrdev(USB_MAJOR, "usb", &usb_fops)) { + int error; + + error = register_chrdev(USB_MAJOR, "usb", &usb_fops); + if (error) { err("unable to get major %d for usb devices", USB_MAJOR); - return -EBUSY; + goto out; + } + + error = class_register(&usb_class); + if (error) { + err("class_register failed for usb devices"); + unregister_chrdev(USB_MAJOR, "usb"); + goto out; } devfs_mk_dir("usb"); - class_register(&usb_class); - return 0; + +out: + return error; } void usb_major_cleanup(void) -- 2.53.0