From: Peter Chen <peter.chen@nxp.com>
To: Zhang Qilong <zhangqilong3@huawei.com>
Cc: "balbi@kernel.org" <balbi@kernel.org>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: [PATCH 2/2] usb: gadget: Fix memleak in gadgetfs_fill_super
Date: Mon, 16 Nov 2020 13:04:17 +0000 [thread overview]
Message-ID: <20201116130349.GC28313@b29397-desktop> (raw)
In-Reply-To: <20201116121710.1546690-3-zhangqilong3@huawei.com>
On 20-11-16 20:17:10, 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>
> ---
> 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..3cefc27be098 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:
> + free(CHIP);
> + CHIP = NULL;
> +
> return -ENOMEM;
> }
It seems the dev_new also allocate the memory, would you please change
it too, also, create a new goto entry for it.
--
Thanks,
Peter Chen
next prev parent reply other threads:[~2020-11-16 13:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-16 12:17 [PATCH 0/2] usb: gadget: Fix two memleaks in error handling Zhang Qilong
2020-11-16 12:17 ` [PATCH 1/2] usb: gadget: f_midi: Fix memleak in f_midi_alloc Zhang Qilong
2020-11-16 12:59 ` Peter Chen
2020-11-16 16:12 ` Sergei Shtylyov
2020-11-16 12:17 ` [PATCH 2/2] usb: gadget: Fix memleak in gadgetfs_fill_super Zhang Qilong
2020-11-16 13:04 ` Peter Chen [this message]
2020-11-17 1:44 ` 答复: " zhangqilong
2020-11-16 15:06 ` kernel test robot
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=20201116130349.GC28313@b29397-desktop \
--to=peter.chen@nxp.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--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).