Comment 24 for bug 357724

Revision history for this message
GertjanVD (gertjanvd) wrote :

I am not 100% sure of this, but here is what I found.

I checked the video_unregister_device which calls device_unregister.

In drivers/base/core.c:
 * device_unregister - unregister device from system.
 * We do this in two parts, like we do device_register(). First,
 * we remove it from all the subsystems with device_del(), then
 * we decrement the reference count via put_device(). If that
 * is the final reference count, the device will be cleaned up
 * via device_release() above. Otherwise, the structure will
 * stick around until the final reference to the device is dropped.

and

 * device_release - free device structure.
 * This is called once the reference count for the object
 * reaches 0. We forward the call to the device's release
 * method, which should handle actually freeing the structure.

In device_release:
        if (dev->release)
                dev->release(dev);

I think this causes the release to be called twice if the device fails to register. Is this correct?