summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/config.c
diff options
context:
space:
mode:
authorHemant Kumar <hemantk@codeaurora.org>2021-04-21 22:47:32 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-04-22 09:57:48 +0300
commit43c4cab006f55b6ca549dd1214e22f5965a8675f (patch)
treeed4a1b1464c51a6c68813f55648f71e9df76bdbb /drivers/usb/gadget/config.c
parent374157ff88ae1a7f7927331cbc72c1ec11994e8a (diff)
downloadlinux-43c4cab006f55b6ca549dd1214e22f5965a8675f.tar.xz
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: f5c61225cf29 ("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>
Diffstat (limited to 'drivers/usb/gadget/config.c')
-rw-r--r--drivers/usb/gadget/config.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index 2d115353424c..8bb25773b61e 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -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);