lkml.org 
[lkml]   [2014]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] usbip/userspace/libsrc/names.c: memory leak
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



\
 
 \ /
  Last update: 2014-01-28 00:21    [W:0.108 / U:0.448 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site