public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] usbip/userspace/libsrc/names.c: memory leak
@ 2014-01-27 22:29 xypron.glpk
  2014-01-27 22:50 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: xypron.glpk @ 2014-01-27 22:29 UTC (permalink / raw)
  To: devel
  Cc: gregkh, ly80toro, ke42caxa, linux-usb, linux-kernel,
	Heinrich Schuchardt

From: Heinrich Schuchardt <xypron.glpk@gmx.de>

p is freed if NULL.
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;
 	}
 
 	p->mem = calloc(1, size);
 	if (!p->mem)
+		free(p);
 		return NULL;
 
 	p->next = pool_head;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-01-28 20:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-27 22:29 [PATCH 1/1] usbip/userspace/libsrc/names.c: memory leak xypron.glpk
2014-01-27 22:50 ` Greg KH
2014-01-27 23:02   ` Dan Carpenter
2014-01-27 23:27     ` Greg KH
2014-01-28  0:04       ` Dan Carpenter
2014-01-27 22:52 ` Dan Carpenter
2014-01-28 20:16   ` xypron.glpk
2014-01-27 23:52 ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox