From: Alan Stern <stern@rowland.harvard.edu>
To: Zhang Qilong <zhangqilong3@huawei.com>
Cc: peter.chen@nxp.com, balbi@kernel.org, gregkh@linuxfoundation.org,
sergei.shtylyov@gmail.com, linux-usb@vger.kernel.org
Subject: Re: [PATCH v2 2/2] usb: gadget: Fix memleak in gadgetfs_fill_super
Date: Thu, 19 Nov 2020 10:50:09 -0500 [thread overview]
Message-ID: <20201119155009.GA573796@rowland.harvard.edu> (raw)
In-Reply-To: <20201117021629.1470544-3-zhangqilong3@huawei.com>
On Tue, Nov 17, 2020 at 10:16:29AM +0800, Zhang Qilong wrote:
> usb_get_gadget_udc_name will alloc memory for CHIP
> in "Enomem" branch. we should free it before error
> returns to prevent memleak.
>
> Fixes: 175f712119c57 ("usb: gadget: provide interface for legacy gadgets to get UDC name")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
> ---
Acked-by: Alan Stern <stern@rowland.harvard.edu>
> Changelog:
> v2
> - replace free with kfree.
> ---
> drivers/usb/gadget/legacy/inode.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
> index 1b430b36d0a6..71e7d10dd76b 100644
> --- a/drivers/usb/gadget/legacy/inode.c
> +++ b/drivers/usb/gadget/legacy/inode.c
> @@ -2039,6 +2039,9 @@ gadgetfs_fill_super (struct super_block *sb, struct fs_context *fc)
> return 0;
>
> Enomem:
> + kfree(CHIP);
> + CHIP = NULL;
> +
> return -ENOMEM;
> }
>
prev parent reply other threads:[~2020-11-19 15:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-17 2:16 [PATCH v2 0/2] usb: gadget: Fix two memleaks in error handling Zhang Qilong
2020-11-17 2:16 ` [PATCH v2 1/2] usb: gadget: f_midi: Fix memleak in f_midi_alloc Zhang Qilong
2020-11-17 2:16 ` [PATCH v2 2/2] usb: gadget: Fix memleak in gadgetfs_fill_super Zhang Qilong
2020-11-19 15:50 ` Alan Stern [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=20201119155009.GA573796@rowland.harvard.edu \
--to=stern@rowland.harvard.edu \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.chen@nxp.com \
--cc=sergei.shtylyov@gmail.com \
--cc=zhangqilong3@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).