From: Alan Stern <stern@rowland.harvard.edu>
To: Hangyu Hua <hbh25y@gmail.com>
Cc: balbi@kernel.org, gregkh@linuxfoundation.org, axboe@kernel.dk,
dan.carpenter@oracle.com, jj251510319013@gmail.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/2] usb: gadget: don't release an existing dev->buf
Date: Fri, 31 Dec 2021 12:34:46 -0500 [thread overview]
Message-ID: <Yc8/Nsr9pPAqgtK/@rowland.harvard.edu> (raw)
In-Reply-To: <20211231172138.7993-2-hbh25y@gmail.com>
On Sat, Jan 01, 2022 at 01:21:37AM +0800, Hangyu Hua wrote:
> dev->buf does not need to be released if it already exists before
> executing dev_config.
>
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> ---
Acked-by: Alan Stern <stern@rowland.harvard.edu>
> drivers/usb/gadget/legacy/inode.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
> index 3b58f4fc0a80..eaad03c0252f 100644
> --- a/drivers/usb/gadget/legacy/inode.c
> +++ b/drivers/usb/gadget/legacy/inode.c
> @@ -1826,8 +1826,9 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
> spin_lock_irq (&dev->lock);
> value = -EINVAL;
> if (dev->buf) {
> + spin_unlock_irq(&dev->lock);
> kfree(kbuf);
> - goto fail;
> + return value;
> }
> dev->buf = kbuf;
>
> --
> 2.25.1
>
next prev parent reply other threads:[~2021-12-31 17:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-31 17:21 [PATCH v4 0/2] usb: gadget: use after free in dev_config Hangyu Hua
2021-12-31 17:21 ` [PATCH v4 1/2] usb: gadget: don't release an existing dev->buf Hangyu Hua
2021-12-31 17:34 ` Alan Stern [this message]
2021-12-31 17:21 ` [PATCH v4 2/2] usb: gadget: clear related members when goto fail Hangyu Hua
2021-12-31 17:35 ` Alan Stern
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=Yc8/Nsr9pPAqgtK/@rowland.harvard.edu \
--to=stern@rowland.harvard.edu \
--cc=axboe@kernel.dk \
--cc=balbi@kernel.org \
--cc=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=hbh25y@gmail.com \
--cc=jj251510319013@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox