From: Heinrich Schuchardt Date: Tue, 28 Jan 2014 20:16:46 +0000 (+0100) Subject: usbip/userspace/libsrc/names.c: memory leak X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2a7470d9ffe506ff895f4a27dcf3840cb3ea097f;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git usbip/userspace/libsrc/names.c: memory leak revised patch p is freed if NULL. p is leaked if second calloc fails. Signed-off-by: Heinrich Schuchardt Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/usbip/userspace/libsrc/names.c b/drivers/staging/usbip/userspace/libsrc/names.c index 3c8d28b771e0..81ff8522405c 100644 --- a/drivers/staging/usbip/userspace/libsrc/names.c +++ b/drivers/staging/usbip/userspace/libsrc/names.c @@ -169,14 +169,14 @@ static void *my_malloc(size_t size) struct pool *p; p = calloc(1, sizeof(struct pool)); - if (!p) { - free(p); + if (!p) return NULL; - } p->mem = calloc(1, size); - if (!p->mem) + if (!p->mem) { + free(p); return NULL; + } p->next = pool_head; pool_head = p;