• Jerry Zhang's avatar
    usb: gadget: f_midi: Use snd_card_free_when_closed with refcount · 2d19cdc1
    Jerry Zhang authored
    Currenly, f_midi_free uses snd_card_free, which will wait
    until the user has released the sound card before
    returning. However, if the user doesn't release the sound
    card, then f_midi_free can block for an arbitrary amount
    of time, which also blocks any gadget operations on that
    thread.
    
    Instead, we can use snd_card_free_when_closed which returns
    before all handles are released. Since f_midi can be
    accessed through rmidi if usb_put_function is called before
    release_card_device, add refcounting to f_midi_free and
    have rawmidi's private free call it. The f_midi memory
    is only kfreed when usb_put_function and release_card_device
    have both been called.
    Signed-off-by: default avatarJerry Zhang <zhangjerry@google.com>
    Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
    2d19cdc1
f_midi.c 33 KB