Thread (5 messages) 5 messages, 3 authors, 2018-02-02

ohci-hcd: Fix race condition caused by ohci_urb_enqueue() and io_watchdog_func()

From: Yoshida, Shigeru <hidden>
Date: 2018-02-01 05:48:37
Also in: lkml

Hi Alan,

Thank you for your commenting.

On Wed, 31 Jan 2018 11:02:47 -0500, Alan Stern wrote:
quoted
To address above scenario, this patch introduces timer_running flag to
ohci_hcd structure.  Setting true to ohci->timer_running indicates
io_watchdog_func() is scheduled or is running.  ohci_urb_enqueue()
checks the flag when it schedules the watchdog (step 4 and 12 above),
so ohci->prev_frame_no is not overwritten while io_watchdog_func() is
running.
Instead of adding an extra flag variable, which has to be kept in sync 
with the timer routine, how about defining a special sentinel value for 
prev_frame_no?  For example:

#define IO_WATCHDOG_OFF		0xffffff00

Then whenever the timer isn't scheduled or running, set
ohci->prev_frame_no to IO_WATCHDOG_OFF.  And instead of testing
timer_pending(), compare prev_frame_no to this special value.

I think that approach will be slightly more robust.
It's reasonable since ohci->prev_frame_no is not used while the
watchdog timer is stopped.

I think we must choose an invalid frame number for the special
sentinel value, but I'm not sure which value is adequate for it.
Is 0xffffff00 an invalid frame number, otherwise how about simply
-1(0xffffffff)?

Thanks,
Shigeru--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help