[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190923061921.GA96726@LGEARND20B15>
Date: Mon, 23 Sep 2019 15:19:21 +0900
From: Austin Kim <austindh.kim@...il.com>
To: gregkh@...uxfoundation.org, stern@...land.harvard.edu
Cc: linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org,
mathias.nyman@...ux.intel.com, Thinh.Nguyen@...opsys.com,
nsaenzjulienne@...e.de, jflat@...omium.org, malat@...ian.org,
dianders@...omium.org, austindh.kim@...il.com
Subject: [PATCH] usb: hub: Minor refactoring in usb_hub_init()
Normally when creation of workqueue fails, exception handling takes place
after the call to alloc_workqueue() is made.
But looking into usb_hub_init() function, 'return 0' statement is executed,
when alloc_workqueue() returns valid workqueue pointer.
if (hub_wq)
return 0;
This might make other Linux driver developers get confused
because they could deduce that this is exceptional handling routine.
So perform minor refactoring by adding NULL pointer dereference check
routine right after the call to alloc_workqueue() is made.
Signed-off-by: Austin Kim <austindh.kim@...il.com>
---
drivers/usb/core/hub.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index e8ebacc..0ddbfe6 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -5530,9 +5530,12 @@ int usb_hub_init(void)
* over to the companion full-speed controller.
*/
hub_wq = alloc_workqueue("usb_hub_wq", WQ_FREEZABLE, 0);
- if (hub_wq)
- return 0;
+ if (unlikely(!hub_wq))
+ goto err_workqueue;
+
+ return 0;
+err_workqueue:
/* Fall through if kernel_thread failed */
usb_deregister(&hub_driver);
pr_err("%s: can't allocate workqueue for usb hub\n", usbcore_name);
--
2.6.2
Powered by blists - more mailing lists