[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1346535456-28941-1-git-send-email-khoroshilov@ispras.ru>
Date:	Sun,  2 Sep 2012 01:37:36 +0400
From:	Alexey Khoroshilov <khoroshilov@...ras.ru>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:	Alexey Khoroshilov <khoroshilov@...ras.ru>,
	devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
	ldv-project@...ras.ru
Subject: [PATCH] staging: bcm: fix error handling in bcm_init()
bcm_init() does not have proper error handling of usb_register().
The patch implements one.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@...ras.ru>
---
 drivers/staging/bcm/InterfaceInit.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c
index 8f85de6..0049890 100644
--- a/drivers/staging/bcm/InterfaceInit.c
+++ b/drivers/staging/bcm/InterfaceInit.c
@@ -669,6 +669,8 @@ struct class *bcm_class;
 
 static __init int bcm_init(void)
 {
+	int retval;
+
 	printk(KERN_INFO "%s: %s, %s\n", DRV_NAME, DRV_DESCRIPTION, DRV_VERSION);
 	printk(KERN_INFO "%s\n", DRV_COPYRIGHT);
 
@@ -678,7 +680,15 @@ static __init int bcm_init(void)
 		return PTR_ERR(bcm_class);
 	}
 
-	return usb_register(&usbbcm_driver);
+	retval = usb_register(&usbbcm_driver);
+	if (retval < 0) {
+		printk(KERN_ERR DRV_NAME ": could not register usb driver\n");
+		goto out_class;
+	}
+	return 0;
+out_class:
+	class_destroy(bcm_class);
+	return retval;
 }
 
 static __exit void bcm_exit(void)
-- 
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Powered by blists - more mailing lists
 
