Skip to content

Commit

Permalink
CHROMIUM: usb: gadget: f_audio_source: add .free_func callback
Browse files Browse the repository at this point in the history
When userspace unbinds gadget functions through configfs, the
.free_func() callback is always invoked. (in config_usb_cfg_unlink())
Implement it as a no-op to avoid the following crash:

[ 68.125679] configfs-gadget gadget: unbind function 'accessory'/ffffffc0720bf000
[ 68.133202] configfs-gadget gadget: unbind function 'audio_source'/ffffffc0012ca3c0
[ 68.142668] tegra-xudc 700d0000.usb-device: ep 0 disabled
[ 68.148186] Bad mode in Synchronous Abort handler detected, code 0x86000006
[ 68.155144] CPU: 2 PID: 1 Comm: init Tainted: G    U W 3.18.0-09419-g87296c3-dirty torvalds#561
[ 68.163743] Hardware name: Google Tegra210 Smaug Rev 1,3+ (DT)
[ 68.169566] task: ffffffc0bc8d0000 ti: ffffffc0bc8bc000 task.ti: ffffffc0bc8bc000
[ 68.177039] PC is at 0x0
[ 68.179577] LR is at usb_put_function+0x14/0x1c
....

BUG=chrome-os-partner:49140
TEST="setprop sys.usb.config accessory,audio_source" on A44 and then
switch back to default: "setprop sys.usb.config mtp,adb", no crash will
be seen.

Change-Id: I5b6141964aab861e86e3afb139ded02d4d122dab
Signed-off-by: Mark Kuo <mkuo@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/321013
Commit-Ready: Andrew Bresticker <abrestic@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
(cherry picked from commit e7264d37e1c568a25285493e3e2d6df7e5e8d731)
Signed-off-by: Guenter Roeck <groeck@chromium.org>
  • Loading branch information
Mark Kuo authored and Guenter Roeck committed Oct 22, 2018
1 parent 3c02dc9 commit ddd84fa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/usb/gadget/function/f_audio_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,11 @@ static void audio_disable(struct usb_function *f)
usb_ep_disable(audio->in_ep);
}

static void audio_free_func(struct usb_function *f)
{
/* no-op */
}

/*-------------------------------------------------------------------------*/

static void audio_build_desc(struct audio_dev *audio)
Expand Down Expand Up @@ -838,6 +843,7 @@ static struct audio_dev _audio_dev = {
.set_alt = audio_set_alt,
.setup = audio_setup,
.disable = audio_disable,
.free_func = audio_free_func,
},
.lock = __SPIN_LOCK_UNLOCKED(_audio_dev.lock),
.idle_reqs = LIST_HEAD_INIT(_audio_dev.idle_reqs),
Expand Down

0 comments on commit ddd84fa

Please sign in to comment.