[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <52E6F12D.90701@cogentembedded.com>
Date: Tue, 28 Jan 2014 02:52:13 +0300
From: Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To: xypron.glpk@....de, devel@...verdev.osuosl.org
CC: gregkh@...uxfoundation.org, ly80toro@....cs.fau.de,
ke42caxa@....cs.fau.de, linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] usbip/userspace/libsrc/names.c: memory leak
Hello.
On 01/28/2014 01:29 AM, xypron.glpk@....de wrote:
> From: Heinrich Schuchardt <xypron.glpk@....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@....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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists