[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171222073517.8773-1-tommi.t.rantala@nokia.com>
Date: Fri, 22 Dec 2017 09:35:16 +0200
From: Tommi Rantala <tommi.t.rantala@...ia.com>
To: netdev@...r.kernel.org
Cc: Jon Maloy <jon.maloy@...csson.com>,
Ying Xue <ying.xue@...driver.com>,
tipc-discussion@...ts.sourceforge.net,
Tommi Rantala <tommi.t.rantala@...ia.com>
Subject: [PATCH net 1/2] tipc: error path leak fixes in tipc_enable_bearer()
Fix memory leak in tipc_enable_bearer() if enable_media() fails, and
cleanup with bearer_disable() if tipc_mon_create() fails.
Acked-by: Ying Xue <ying.xue@...driver.com>
Acked-by: Jon Maloy <jon.maloy@...csson.com>
Signed-off-by: Tommi Rantala <tommi.t.rantala@...ia.com>
---
net/tipc/bearer.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 47ec121574ce..c8001471da6c 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -324,6 +324,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
if (res) {
pr_warn("Bearer <%s> rejected, enable failure (%d)\n",
name, -res);
+ kfree(b);
return -EINVAL;
}
@@ -347,8 +348,10 @@ static int tipc_enable_bearer(struct net *net, const char *name,
if (skb)
tipc_bearer_xmit_skb(net, bearer_id, skb, &b->bcast_addr);
- if (tipc_mon_create(net, bearer_id))
+ if (tipc_mon_create(net, bearer_id)) {
+ bearer_disable(net, b);
return -ENOMEM;
+ }
pr_info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
name,
--
2.14.3
Powered by blists - more mailing lists