Skip to content

Commit

Permalink
tipc: error path leak fixes in tipc_enable_bearer()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Jon Maloy <[email protected]>
Signed-off-by: Tommi Rantala <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
rantala authored and davem330 committed Dec 27, 2017
1 parent 14e138a commit 1914255
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/tipc/bearer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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,
Expand Down

0 comments on commit 1914255

Please sign in to comment.