lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 19 Sep 2014 17:32:19 +0200
From:	Petr Mladek <>
To:	Alan Stern <>,
	Greg Kroah-Hartman <>
Cc:	Tejun Heo <>, Joe Lawrence <>,
	Jiri Kosina <>,,, Petr Mladek <>
Subject: [PATCH v3 1/6] usb: hub: keep hub->dev reference all the time when struct usb_hub lives

This is just a small optimization of the fix from the commit c605f3cdff53a743f6
("usb: hub: take hub->hdev reference when processing from eventlist).

We do not need to take the reference for each event. Instead we could get it
when struct usb_hub is allocated and put it when it is released. By other words,
we could handle it the same way as the reference for hub->intfdev.

The motivation is that it will make the life easier when switching from khubd
kthread to a workqueue.

Suggested-by: Alan Stern <>
Signed-off-by: Petr Mladek <>
 drivers/usb/core/hub.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index d481c99a20d7..8f35e5158daf 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1634,6 +1634,7 @@ static void hub_release(struct kref *kref)
 	struct usb_hub *hub = container_of(kref, struct usb_hub, kref);
+	usb_put_dev(hub->hdev);
@@ -1799,6 +1800,7 @@ descriptor_error:
 	INIT_DELAYED_WORK(&hub->leds, led_work);
 	INIT_DELAYED_WORK(&hub->init_work, NULL);
+	usb_get_dev(hdev);
 	usb_set_intfdata (intf, hub);
 	intf->needs_remote_wakeup = 1;
@@ -5024,10 +5026,9 @@ static void hub_events(void)
 		hub = list_entry(tmp, struct usb_hub, event_list);
-		hdev = hub->hdev;
-		usb_get_dev(hdev);
+		hdev = hub->hdev;
 		hub_dev = hub->intfdev;
 		intf = to_usb_interface(hub_dev);
 		dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
@@ -5140,7 +5141,6 @@ static void hub_events(void)
-		usb_put_dev(hdev);
 		kref_put(&hub->kref, hub_release);
 	} /* end while (1) */

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

Powered by blists - more mailing lists