net/hsr: Better frame dispatch
Subsystems (4)
Hello Arvid Brodin,
The patch f266a683a480: "net/hsr: Better frame dispatch" from Jul 4, 2014, leads to the following static checker warning:
net/hsr/hsr_framereg.c:293 hsr_addr_subst_dest() warn: this array is probably non-NULL. 'node_dst->MacAddressB'
net/hsr/hsr_framereg.c
286 node_dst = find_node_by_AddrA(&port->hsr->node_db, eth_hdr(skb)->h_dest);
287 if (!node_dst) {
288 WARN_ONCE(1, "%s: Unknown node\n", __func__);
289 return;
290 }
291 if (port->type != node_dst->AddrB_port)
292 return;
293 if (!node_dst->MacAddressB) {
^^^^^^^^^^^^^^^^^^^^^^This test is never true. It could be deleted or replaced.
294 WARN_ONCE(1, "%s: No MacAddressB\n", __func__); 295 return; 296 } 297
regards,
dan carpenter
Quoted 18 lines · Dan Carpenter
Hello Arvid Brodin,
The patch
f266a683a480: "net/hsr: Better frame dispatch" from Jul 4, 2014, leads to the following static checker warning:net/hsr/hsr_framereg.c:293 hsr_addr_subst_dest() warn: this array is probably non-NULL. 'node_dst->MacAddressB'
net/hsr/hsr_framereg.c286 node_dst = find_node_by_AddrA(&port->hsr->node_db, eth_hdr(skb)->h_dest); 287 if (!node_dst) { 288 WARN_ONCE(1, "%s: Unknown node\n", __func__); 289 return; 290 } 291 if (port->type != node_dst->AddrB_port) 292 return; 293 if (!node_dst->MacAddressB) { ^^^^^^^^^^^^^^^^^^^^^^
Quoted 7 lines
This test is never true. It could be deleted or replaced.
294 WARN_ONCE(1, "%s: No MacAddressB\n", __func__); 295 return; 296 } 297
Yes, this code (the whole if block; lines 293-296) is useless and should be deleted. Thanks for finding it!
Signature · 8 lines
Arvid Brodin | Consultant (Linux) ALTEN | Knarrarnäsgatan 7 | SE-164 40 Kista | Sweden [email protected] | www.alten.se/en/ -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 net/hsr: Remove left-over never-true conditional code.
In reply to Dan CarpenterMacAddressB is an array (unsigned char MacAddressB[ETH_ALEN]) and is allocated as a part of *node_dst (which is a struct hsr_node). So the condition is always false.
Detected by Dan Carpenter.
--- net/hsr/hsr_framereg.c | 4 ---- 1 file changed, 4 deletions(-)
net/hsr/hsr_framereg.c +0 -4
@@ -290,10 +290,6 @@ void hsr_addr_subst_dest(struct hsr_node *node_src, struct sk_buff *skb, }if (port->type != node_dst->AddrB_port)return ; -if (!node_dst->MacAddressB) { -WARN_ONCE (1 ,"%s: No MacAddressB\n" , __func__); -return ; - }ether_addr_copy (eth_hdr (skb)->h_dest, node_dst->MacAddressB); }
Signature · 10 lines
1.8.3.2 -- Arvid Brodin | Consultant (Linux) ALTEN | Knarrarnäsgatan 7 | SE-164 40 Kista | Sweden [email protected] | www.alten.se/en/ -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next] net/hsr: Remove left-over never-true conditional code.
From: Arvid Brodin <[email protected]>
Date: Fri, 11 Jul 2014 18:21:12 +0200
Quoted 7 lines
MacAddressB is an array (unsigned char MacAddressB[ETH_ALEN]) and is allocated as a part of
*node_dst(which is a structhsr_node). So the condition is always false.Detected by Dan Carpenter.
Signed-off-by Arvid Brodin <[email protected]>
Applied, thanks.