usb: gadget: f_midi: Use refcount when freeing f_midi_opts
authorJerry Zhang <zhangjerry@google.com>
Sat, 31 Mar 2018 00:54:24 +0000 (17:54 -0700)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 15 May 2018 07:08:44 +0000 (10:08 +0300)
commit9286e24b837151a5a59e7403cea3e4a2c33ba225
treee4707c84aa40d0262f832b34a08d43d471deb479
parent7ecca2a4080cb6b1fa174adc588fce9e9014c43c
usb: gadget: f_midi: Use refcount when freeing f_midi_opts

Currently, the midi function is not freed until it is
both removed from the config and released by the user.
Since the user could take a long time to release the
card, it's possible that the function could be unlinked
and thus f_midi_opts would be null when freeing f_midi.

Thus, refcount f_midi_opts and only free it when it is
unlinked and all f_midis have been freed.

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