From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: xypron.glpk@gmx.de, devel@driverdev.osuosl.org
Cc: gregkh@linuxfoundation.org, ly80toro@cip.cs.fau.de,
ke42caxa@cip.cs.fau.de, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] usbip/userspace/libsrc/names.c: memory leak
Date: Tue, 28 Jan 2014 02:52:13 +0300 [thread overview]
Message-ID: <52E6F12D.90701@cogentembedded.com> (raw)
In-Reply-To: <1390861789-8981-1-git-send-email-xypron.glpk@gmx.de>
Hello.
On 01/28/2014 01:29 AM, xypron.glpk@gmx.de wrote:
> From: Heinrich Schuchardt <xypron.glpk@gmx.de>
> p is freed if NULL.
This is not an issue.
> p is leaked if second calloc fails.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> drivers/staging/usbip/userspace/libsrc/names.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/usbip/userspace/libsrc/names.c b/drivers/staging/usbip/userspace/libsrc/names.c
> index 3c8d28b..b2904e8 100644
> --- a/drivers/staging/usbip/userspace/libsrc/names.c
> +++ b/drivers/staging/usbip/userspace/libsrc/names.c
> @@ -170,12 +170,12 @@ static void *my_malloc(size_t size)
>
> p = calloc(1, sizeof(struct pool));
> if (!p) {
> - free(p);
> return NULL;
> }
{} not needed anymore.
>
> p->mem = calloc(1, size);
> if (!p->mem)
> + free(p);
> return NULL;
How about {} around the *if* arm?
WBR, Sergei
prev parent reply other threads:[~2014-01-27 22:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-27 22:29 [PATCH 1/1] usbip/userspace/libsrc/names.c: memory leak xypron.glpk
2014-01-27 22:50 ` Greg KH
2014-01-27 23:02 ` Dan Carpenter
2014-01-27 23:27 ` Greg KH
2014-01-28 0:04 ` Dan Carpenter
2014-01-27 22:52 ` Dan Carpenter
2014-01-28 20:16 ` xypron.glpk
2014-01-27 23:52 ` Sergei Shtylyov [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=52E6F12D.90701@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=ke42caxa@cip.cs.fau.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=ly80toro@cip.cs.fau.de \
--cc=xypron.glpk@gmx.de \
/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.