• Ming Lei's avatar
    firmware loader: fix device lifetime · 0cfc1e1e
    Ming Lei authored
    Callers of request_firmware* must hold the reference count of
    @device, otherwise it is easy to trigger oops since the firmware
    loader device is the child of @device.
    
    This patch adds comments about the usage. In fact, most of drivers
    call request_firmware* in its probe() or open(), so the constraint
    should be reasonable and can be satisfied.
    
    Also this patch holds the reference count of @device before
    schedule_work() in request_firmware_nowait() to avoid that
    the @device is released after request_firmware_nowait returns
    and before the worker function is scheduled.
    Signed-off-by: default avatarMing Lei <ming.lei@canonical.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    0cfc1e1e
firmware_class.c 22.6 KB