浏览代码

USB: fix race between root-hub resume and wakeup requests

The USB core keeps track of pending resume requests for root hubs, in
order to resolve races between wakeup requests and suspends.  However
the code that does this is subject to another race (between wakeup
requests and resumes) because the WAKEUP_PENDING flag is cleared
before the resume occurs, leaving a window in which another wakeup
request might arrive.

This patch (as1447) fixes the problem by clearing the WAKEUP_PENDING
flag after the resume instead of before it.

This fixes Bugzilla #24952.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Paul Bender <pebender@san.rr.com>
Tested-by: warpme <warpme@o2.pl>
Cc: stable <stable@kernel.org> [.36+]
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern 14 年之前
父节点
当前提交
bf3d7d40e4
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      drivers/usb/core/hcd.c

+ 1 - 1
drivers/usb/core/hcd.c

@@ -1955,7 +1955,6 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
 
 
 	dev_dbg(&rhdev->dev, "usb %s%s\n",
 	dev_dbg(&rhdev->dev, "usb %s%s\n",
 			(msg.event & PM_EVENT_AUTO ? "auto-" : ""), "resume");
 			(msg.event & PM_EVENT_AUTO ? "auto-" : ""), "resume");
-	clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags);
 	if (!hcd->driver->bus_resume)
 	if (!hcd->driver->bus_resume)
 		return -ENOENT;
 		return -ENOENT;
 	if (hcd->state == HC_STATE_RUNNING)
 	if (hcd->state == HC_STATE_RUNNING)
@@ -1963,6 +1962,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
 
 
 	hcd->state = HC_STATE_RESUMING;
 	hcd->state = HC_STATE_RESUMING;
 	status = hcd->driver->bus_resume(hcd);
 	status = hcd->driver->bus_resume(hcd);
+	clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags);
 	if (status == 0) {
 	if (status == 0) {
 		/* TRSMRCY = 10 msec */
 		/* TRSMRCY = 10 msec */
 		msleep(10);
 		msleep(10);