Browse Source

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 <xypron.glpk@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Heinrich Schuchardt 11 years ago
parent
commit
2a7470d9ff
1 changed files with 4 additions and 4 deletions
  1. 4 4
      drivers/staging/usbip/userspace/libsrc/names.c

+ 4 - 4
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;