vxlan: Wrong type passed to %pIS
Subsystems (2)
PATCH 1/1 vxlan: Wrong type passed to %pIS
src_ip is a pointer to a union vxlan_addr, one member of which is a struct sockaddr. Passing a pointer to src_ip is wrong; one should pass the value of src_ip itself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.
--- drivers/net/vxlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/vxlan.c +1 -1
@@ -991,7 +991,7 @@ static bool vxlan_snoop(struct net_device *dev,if (net_ratelimit ())netdev_info (dev,"%pM migrated from %pIS to %pIS\n" , - src_mac, &rdst->remote_ip, &src_ip); + src_mac, &rdst->remote_ip.sa, &src_ip->sa); rdst->remote_ip = *src_ip; f->updated = jiffies;
Signature · 1 line
2.1.3
Quoted 5 lines · Rasmus Villemoes
src_ipis a pointer to a unionvxlan_addr, one member of which is a struct sockaddr. Passing a pointer tosrc_ipis wrong; one should pass the value ofsrc_ipitself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.
Hello Rasmus
Are you finding these mismatches by hand or
are you using some tool?
Quoted 11 lines · Joe Perches
Quoted 5 lines · Rasmus Villemoes
src_ipis a pointer to a unionvxlan_addr, one member of which is a struct sockaddr. Passing a pointer tosrc_ipis wrong; one should pass the value ofsrc_ipitself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.Hello Rasmus
Are you finding these mismatches by hand or
are you using some tool?
I've extended smatch to do format checking (mostly for the %p extensions; gcc already does all the other stuff just fine). I'll try and see if I can get it on github sometime in the coming week.
Rasmus
Quoted 6 lines · Rasmus Villemoes
src_ipis a pointer to a unionvxlan_addr, one member of which is a struct sockaddr. Passing a pointer tosrc_ipis wrong; one should pass the value ofsrc_ipitself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.
It is a union, this doesn't harm.
Quoted 11 lines
Fixes e4c7ed415387 ("vxlan: add ipv6 support")Signed-off-by Rasmus Villemoes <[email protected]>--- drivers/net/vxlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/vxlan.c +0
-0
drivers/net/vxlan.c static bool vxlan_snoop(struct net_device *dev, · line 997
Quoted 8 lines
drivers/net/vxlan.c +1
-1@@ -991,7 +991,7 @@ static bool vxlan_snoop(struct net_device *dev,if (net_ratelimit ())netdev_info (dev,"%pM migrated from %pIS to %pIS\n" , - src_mac, &rdst->remote_ip, &src_ip); + src_mac, &rdst->remote_ip.sa, &src_ip->sa); rdst->remote_ip = *src_ip; f->updated = jiffies;
Since you are on it, there is another similar place in vxlan too.
Quoted 10 lines · Cong Wang
Quoted 6 lines · Rasmus Villemoes
src_ipis a pointer to a unionvxlan_addr, one member of which is a struct sockaddr. Passing a pointer tosrc_ipis wrong; one should pass the value ofsrc_ipitself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.
Quoted 2 lines
It is a union, this doesn't harm.
Just to be clear: This fixes a real bug. The minimal fix had been
- src_mac, &rdst->remote_ip, &src_ip);
+ src_mac, &rdst->remote_ip, src_ip);
but I through in the cosmetic improvements while the line needed changing anyway.
Quoted 1 line
Since you are on it, there is another similar place in vxlan too.
... which is why I didn't change that other occurrence.
Rasmus
Cong Wang
Acked-byQuoted 20 lines · Rasmus Villemoes
Quoted 10 lines · Cong Wang
Quoted 6 lines · Rasmus Villemoes
src_ipis a pointer to a unionvxlan_addr, one member of which is a struct sockaddr. Passing a pointer tosrc_ipis wrong; one should pass the value ofsrc_ipitself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.Quoted 2 lines
It is a union, this doesn't harm.
Just to be clear: This fixes a real bug. The minimal fix had been
(quoted diff) +1
-1- src_mac, &rdst->remote_ip, &src_ip); + src_mac, &rdst->remote_ip, src_ip);
Quoted 3 lines
but I through in the cosmetic improvements while the line needed changing anyway.
Ah, I misread the patch.
Thanks!
From: Rasmus Villemoes <[email protected]>
Date: Sat, 7 Feb 2015 03:17:31 +0100
Quoted 8 lines
src_ipis a pointer to a unionvxlan_addr, one member of which is a struct sockaddr. Passing a pointer tosrc_ipis wrong; one should pass the value ofsrc_ipitself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.Fixes e4c7ed415387 ("vxlan: add ipv6 support")Signed-off-by Rasmus Villemoes <[email protected]>
Applied, thanks.