Message ID | b9646b4a-61a2-41fb-8fea-ba63e08996f3@web.de (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | tipc: Improve exception handling in tipc_bcast_init() | expand |
>Subject: [PATCH] tipc: Improve exception handling in tipc_bcast_init() > >From: Markus Elfring <elfring@users.sourceforge.net> >Date: Sun, 31 Dec 2023 12:20:06 +0100 > >The kfree() function was called in two cases by the tipc_bcast_init() function during error handling even if the passed variable >contained a null pointer. >This issue was detected by using the Coccinelle software. kfree() validates the pointer before doing actual memory free. Your patch is not necessary.
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 593846d25214..631aef2dde45 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c @@ -688,13 +688,15 @@ int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[]) int tipc_bcast_init(struct net *net) { - struct tipc_net *tn = tipc_net(net); - struct tipc_bc_base *bb = NULL; - struct tipc_link *l = NULL; + struct tipc_net *tn; + struct tipc_bc_base *bb; + struct tipc_link *l; bb = kzalloc(sizeof(*bb), GFP_KERNEL); if (!bb) - goto enomem; + return -ENOMEM; + + tn = tipc_net(net); tn->bcbase = bb; spin_lock_init(&tipc_net(net)->bclock); @@ -715,7 +717,6 @@ int tipc_bcast_init(struct net *net) return 0; enomem: kfree(bb); - kfree(l); return -ENOMEM; }