FROMGIT: usb: gadget: Fix double free of device descriptor pointers
Upon driver unbind usb_free_all_descriptors() function frees all speed descriptor pointers without setting them to NULL. In case gadget speed changes (i.e from super speed plus to super speed) after driver unbind only upto super speed descriptor pointers get populated. Super speed plus desc still holds the stale (already freed) pointer. Fix this issue by setting all descriptor pointers to NULL after freeing them in usb_free_all_descriptors(). Fixes:f5c61225cf("usb: gadget: Update function for SuperSpeedPlus") cc: stable@vger.kernel.org Reviewed-by: Peter Chen <peter.chen@kernel.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org> Signed-off-by: Wesley Cheng <wcheng@codeaurora.org> Link: https://lore.kernel.org/r/1619034452-17334-1-git-send-email-wcheng@codeaurora.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit43c4cab006https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next) Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I24ed655c590ebe82f8e665882acdc4b0e4c1d9a9
This commit is contained in:
parent
3f315db5f8
commit
fcd2a56bb0
1 changed files with 4 additions and 0 deletions
|
|
@ -194,9 +194,13 @@ EXPORT_SYMBOL_GPL(usb_assign_descriptors);
|
|||
void usb_free_all_descriptors(struct usb_function *f)
|
||||
{
|
||||
usb_free_descriptors(f->fs_descriptors);
|
||||
f->fs_descriptors = NULL;
|
||||
usb_free_descriptors(f->hs_descriptors);
|
||||
f->hs_descriptors = NULL;
|
||||
usb_free_descriptors(f->ss_descriptors);
|
||||
f->ss_descriptors = NULL;
|
||||
usb_free_descriptors(f->ssp_descriptors);
|
||||
f->ssp_descriptors = NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(usb_free_all_descriptors);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue