Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: u_audio: Clear uac pointer when freed.

This prevents use of a stale pointer if functions are called after
g_cleanup that shouldn't be. This doesn't fix any races, but converts
a possibly silent kernel memory corruption into an obvious NULL pointer
dereference report.

Fixes: eb9fecb9e69b ("usb: gadget: f_uac2: split out audio core")
Signed-off-by: Chris Wulff <chris.wulff@biamp.com>
Link: https://lore.kernel.org/stable/CO1PR17MB54194226DA08BFC9EBD8C163E1172%40CO1PR17MB5419.namprd17.prod.outlook.com
Link: https://lore.kernel.org/r/CO1PR17MB54194226DA08BFC9EBD8C163E1172@CO1PR17MB5419.namprd17.prod.outlook.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Chris Wulff and committed by
Greg Kroah-Hartman
a2cf936e 1b739388

+2
+2
drivers/usb/gadget/function/u_audio.c
··· 1420 1420 return; 1421 1421 1422 1422 uac = g_audio->uac; 1423 + g_audio->uac = NULL; 1424 + 1423 1425 card = uac->card; 1424 1426 if (card) 1425 1427 snd_card_free_when_closed(card);