Netdev List
 help / color / mirror / Atom feed
* [PATCH net 1/2] tipc: error path leak fixes in tipc_enable_bearer()
@ 2017-12-22  7:35 Tommi Rantala
  2017-12-22  7:35 ` [PATCH net 2/2] tipc: fix tipc_mon_delete() oops in tipc_enable_bearer() error path Tommi Rantala
  2017-12-27 15:56 ` [PATCH net 1/2] tipc: error path leak fixes in tipc_enable_bearer() David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Tommi Rantala @ 2017-12-22  7:35 UTC (permalink / raw)
  To: netdev; +Cc: Jon Maloy, Ying Xue, tipc-discussion, Tommi Rantala

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@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.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

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

end of thread, other threads:[~2017-12-27 15:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-22  7:35 [PATCH net 1/2] tipc: error path leak fixes in tipc_enable_bearer() Tommi Rantala
2017-12-22  7:35 ` [PATCH net 2/2] tipc: fix tipc_mon_delete() oops in tipc_enable_bearer() error path Tommi Rantala
2017-12-27 15:56   ` David Miller
2017-12-27 15:56 ` [PATCH net 1/2] tipc: error path leak fixes in tipc_enable_bearer() David Miller

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