vxlan: Move socket initialization to within rtnl scope
Subsystems (3)
Hello Marcelo Ricardo Leitner,
This is a semi-automatic email about new static checker warnings.
The patch 56ef9c909b40: "vxlan: Move socket initialization to within rtnl scope" from Mar 18, 2015, leads to the following Smatch complaint:
drivers/net/vxlan.c:2267 vxlan_stop()
error: we previously assumed 'vs' could be null (see line 2257)
drivers/net/vxlan.c
2256
2257 if (vs && vxlan_addr_multicast(&vxlan->default_dst.remote_ip) &&
^^
Existing code assumed "vs" could be NULL.
2258 !vxlan_group_used(vn, vxlan)) {
2259 ret = vxlan_igmp_leave(vxlan);
2260 if (ret)
2261 return ret;
2262 }
2263
2264 del_timer_sync(&vxlan->age_timer);
2265
2266 vxlan_flush(vxlan);
2267 vxlan_sock_release(vs);
^^Patch adds new unchecked dereference.
2268
2269 return ret;
regards,
dan carpenter
PATCH 1/1 vxlan: simplify if clause in dev_close
Dan Carpenter's static checker warned that in vxlan_stop we are checking if 'vs' can be NULL while later we simply derreference it.
As after commit 56ef9c909b40 ("vxlan: Move socket initialization to within rtnl scope") 'vs' just cannot be NULL in vxlan_stop() anymore, as the interface won't go up if the socket initialization fails. So we are good to just remove the check and make it consistent.
--- drivers/net/vxlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/vxlan.c +1 -1
@@ -2254,7 +2254,7 @@ static int vxlan_stop(struct net_device *dev)struct vxlan_sock *vs = vxlan->vn_sock;int ret =0 ; -if (vs &&vxlan_addr_multicast (&vxlan->default_dst.remote_ip) && +if (vxlan_addr_multicast (&vxlan->default_dst.remote_ip) && !vxlan_group_used (vn, vxlan)) { ret =vxlan_igmp_leave (vxlan);if (ret)
Signature · 1 line
2.3.3
Re: [PATCH net-next] vxlan: simplify if clause in dev_close
From: Marcelo Ricardo Leitner <[email protected]>
Date: Mon, 23 Mar 2015 16:23:12 -0300
Quoted 10 lines
Dan Carpenter's static checker warned that in
vxlan_stopwe are checking if 'vs' can be NULL while later we simply derreference it.As after commit
56ef9c909b40("vxlan: Move socket initialization to within rtnl scope") 'vs' just cannot be NULL invxlan_stop()anymore, as the interface won't go up if the socket initialization fails. So we are good to just remove the check and make it consistent.Reported-by Dan Carpenter <[email protected]>Signed-off-by Marcelo Ricardo Leitner <[email protected]>
Applied, thanks.