Message ID | 20220303045717.30232-1-tung.q.nguyen@dektech.com.au (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,1/1] tipc: fix kernel panic when enabling bearer | expand |
On Thu, 3 Mar 2022 04:57:17 +0000 Tung Nguyen wrote: > diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c > index 473a790f5894..63460183440d 100644 > --- a/net/tipc/bearer.c > +++ b/net/tipc/bearer.c > @@ -252,7 +252,7 @@ static int tipc_enable_bearer(struct net *net, const char *name, > int with_this_prio = 1; > struct tipc_bearer *b; > struct tipc_media *m; > - struct sk_buff *skb; > + struct sk_buff *skb = NULL; > int bearer_id = 0; > int res = -EINVAL; > char *errstr = ""; This chunk looks unrelated and unnecessary. The had previously trusted skb to be initialized by tipc_disc_create().
On Thu, 3 Mar 2022 04:57:17 +0000 Tung Nguyen wrote: > diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c > index 473a790f5894..63460183440d 100644 > --- a/net/tipc/bearer.c > +++ b/net/tipc/bearer.c > @@ -252,7 +252,7 @@ static int tipc_enable_bearer(struct net *net, const char *name, > int with_this_prio = 1; > struct tipc_bearer *b; > struct tipc_media *m; > - struct sk_buff *skb; > + struct sk_buff *skb = NULL; > int bearer_id = 0; > int res = -EINVAL; > char *errstr = ""; This chunk looks unrelated and unnecessary. The had previously trusted skb to be initialized by tipc_disc_create(). [Tung]: OK. I will remove it in v2.
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 473a790f5894..63460183440d 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c @@ -252,7 +252,7 @@ static int tipc_enable_bearer(struct net *net, const char *name, int with_this_prio = 1; struct tipc_bearer *b; struct tipc_media *m; - struct sk_buff *skb; + struct sk_buff *skb = NULL; int bearer_id = 0; int res = -EINVAL; char *errstr = ""; @@ -352,16 +352,18 @@ static int tipc_enable_bearer(struct net *net, const char *name, goto rejected; } - test_and_set_bit_lock(0, &b->up); - rcu_assign_pointer(tn->bearer_list[bearer_id], b); - if (skb) - tipc_bearer_xmit_skb(net, bearer_id, skb, &b->bcast_addr); - + /* Create monitoring data before accepting activate messages */ if (tipc_mon_create(net, bearer_id)) { bearer_disable(net, b); + kfree_skb(skb); return -ENOMEM; } + test_and_set_bit_lock(0, &b->up); + rcu_assign_pointer(tn->bearer_list[bearer_id], b); + if (skb) + tipc_bearer_xmit_skb(net, bearer_id, skb, &b->bcast_addr); + pr_info("Enabled bearer <%s>, priority %u\n", name, prio); return res;