• Alan Stern's avatar
    [PATCH] USB: Lock devices during tree traversal · 59c2deed
    Alan Stern authored
    On Tue, 27 Apr 2004, Greg KH wrote:
    
    > So, what's next in this patch series?  :)
    
    Funny you should ask...
    
    While writing those patches I noted a problem, that the USB device tree
    can change while a process reading /proc/bus/usb/devices is traversing it,
    leading to an oops when a pointer to a no-longer-existing child device is
    dereferenced.  The ensuing discussion led to the conclusion that the
    devices' ->serialize locks should be acquired, top-down, while going
    through the tree.
    
    That means changing the code that populates the devices file and changing
    the code that adds and removes USB device structures.  This patch takes
    care of the first part.  I'm delaying the second part because that section
    of usbcore is still under change -- David Brownell's revisions have not
    yet been fully integrated.
    
    A similar change should be made to usb_find_device() and match_device() in
    usb.c.  You may want to add that yourself.
    59c2deed
devices.c 18.6 KB