aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2014-04-24 22:44:15 -0400
committerDavid S. Miller <davem@davemloft.net>2014-04-27 19:08:06 -0400
commit22e7987ae7d8d13beeaf0717215800f7e803ddcf (patch)
treebf796b7b8020397483e5a2ed4bc6b48dd7a6cb86 /net/tipc
parenta42c3a28e8c2f071749a051f3afdbc1777418a07 (diff)
tipc: fix a possible memory leak
The commit a8b9b96e959f3c035af20b1bd2ba67b0b7269b19 ("tipc: fix race in disc create/delete") leads to the following static checker warning: net/tipc/discover.c:352 tipc_disc_create() warn: possible memory leak of 'req' The risk of memory leak really exists in practice. Especially when it's failed to allocate memory for "req->buf", tipc_disc_create() doesn't free its allocated memory, instead just directly returns with ENOMEM error code. In this situation, memory leak, of course, happens. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/discover.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index ada42e436f5e..bd35c4a0746f 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -348,8 +348,10 @@ int tipc_disc_create(struct tipc_bearer *b_ptr, struct tipc_media_addr *dest)
348 return -ENOMEM; 348 return -ENOMEM;
349 349
350 req->buf = tipc_buf_acquire(INT_H_SIZE); 350 req->buf = tipc_buf_acquire(INT_H_SIZE);
351 if (!req->buf) 351 if (!req->buf) {
352 kfree(req);
352 return -ENOMEM; 353 return -ENOMEM;
354 }
353 355
354 tipc_disc_init_msg(req->buf, DSC_REQ_MSG, b_ptr); 356 tipc_disc_init_msg(req->buf, DSC_REQ_MSG, b_ptr);
355 memcpy(&req->dest, dest, sizeof(*dest)); 357 memcpy(&req->dest, dest, sizeof(*dest));