From: Peter Chen <peter.chen@kernel.org>
To: Wesley Cheng <wcheng@codeaurora.org>
Cc: balbi@kernel.org, gregkh@linuxfoundation.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
jackp@codeaurora.org, Hemant Kumar <hemantk@codeaurora.org>
Subject: Re: [PATCH] usb: gadget: Fix double free of device descriptor pointers
Date: Tue, 20 Apr 2021 08:54:29 +0800 [thread overview]
Message-ID: <20210420005429.GA5069@nchen> (raw)
In-Reply-To: <1618862240-5965-1-git-send-email-wcheng@codeaurora.org>
On 21-04-19 12:57:20, Wesley Cheng wrote:
> From: Hemant Kumar <hemantk@codeaurora.org>
>
> 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().
>
> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
> Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
> ---
> drivers/usb/gadget/config.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
> index 2d11535..8bb2577 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);
>
Reviewed-by: Peter Chen <peter.chen@kernel.org>
You may add Fixed-by tag, and cc to stable tree.
--
Thanks,
Peter Chen
prev parent reply other threads:[~2021-04-20 0:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-19 19:57 [PATCH] usb: gadget: Fix double free of device descriptor pointers Wesley Cheng
2021-04-20 0:54 ` Peter Chen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210420005429.GA5069@nchen \
--to=peter.chen@kernel.org \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hemantk@codeaurora.org \
--cc=jackp@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=wcheng@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.