Re: [PATCH 1/1] usbip/userspace/libsrc/names.c: memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 27, 2014 at 11:29:48PM +0100, xypron.glpk@xxxxxx wrote:
> From: Heinrich Schuchardt <xypron.glpk@xxxxxx>

Fix your email account so we can get this automatically from your email.
Currently the From header on your email is just:

From: xypron.glpk@xxxxxx

without your name.

> 
> p is freed if NULL.
> p is leaked if second calloc fails.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@xxxxxx>
> ---
>  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;
>  	}

Remove the curly braces from here since they are no longer needed.

>  
>  	p->mem = calloc(1, size);
>  	if (!p->mem)
> +		free(p);
>  		return NULL;

Add the curly braces here.  They are required.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux