• Patrick Mochel's avatar
    driver model: make device_unregister() only mark device as !present. · 65d20c54
    Patrick Mochel authored
    There are races WRT walking the lists of the buses and classes and the 
    device being unregistered while it's the current node we're accessing. If 
    the node was deleted, ->next would point to itself, and we'd sit in an
    inifinite loop (until that memory was freed from underneath us and we Oops'd).
    
    This changes device_unregister() to only mark the device as not present. put_device()
    deletes the device from all the lists it belongs to, while holding device_lock,
    then drops it to call device_del().
    
    This should guarantee that everything in the device is valid until the last reference
    goes away, regardless of whether it's still physically present or not. 
    65d20c54
core.c 7.4 KB