Skip to content

Commit

Permalink
udp_tunnel: Fix end of loop test in udp_tunnel_nic_unregister()
Browse files Browse the repository at this point in the history
commit de7b2ef upstream.

This test is checking if we exited the list via break or not.  However
if it did not exit via a break then "node" does not point to a valid
udp_tunnel_nic_shared_node struct.  It will work because of the way
the structs are laid out it's the equivalent of
"if (info->shared->udp_tunnel_nic_info != dev)" which will always be
true, but it's not the right way to test.

Fixes: 74cc6d1 ("udp_tunnel: add the ability to share port tables")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and gregkh committed Mar 2, 2022
1 parent a184f4d commit 1c59128
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/ipv4/udp_tunnel_nic.c
Expand Up @@ -846,7 +846,7 @@ udp_tunnel_nic_unregister(struct net_device *dev, struct udp_tunnel_nic *utn)
list_for_each_entry(node, &info->shared->devices, list)
if (node->dev == dev)
break;
if (node->dev != dev)
if (list_entry_is_head(node, &info->shared->devices, list))
return;

list_del(&node->list);
Expand Down

0 comments on commit 1c59128

Please sign in to comment.