]> asedeno.scripts.mit.edu Git - linux.git/commit
usb: gadget: f_midi: Use snd_card_free_when_closed with refcount
authorJerry Zhang <zhangjerry@google.com>
Mon, 14 Aug 2017 21:14:51 +0000 (14:14 -0700)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 15 Aug 2017 11:18:47 +0000 (14:18 +0300)
commit2d19cdc1cb7ab00003fccb951d6199b8d8c9ac67
treea760bb4578621387011ecf34b5a2235904df2325
parent24cf34595d560de0d8eccd6617b7ca5b4ef93d3e
usb: gadget: f_midi: Use snd_card_free_when_closed with refcount

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: Jerry Zhang <zhangjerry@google.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/function/f_midi.c