diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2022-02-22 14:43:12 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-02-23 13:35:40 +0100 |
commit | a1f8fec4dac8bc7b172b2bdbd881e015261a6322 (patch) | |
tree | 84ecbf4763058ce5a74af824eb1af1bd588c6bbd /net/tipc/name_table.c | |
parent | udp_tunnel: Fix end of loop test in udp_tunnel_nic_unregister() (diff) | |
download | linux-a1f8fec4dac8bc7b172b2bdbd881e015261a6322.tar.xz linux-a1f8fec4dac8bc7b172b2bdbd881e015261a6322.zip |
tipc: Fix end of loop tests for list_for_each_entry()
These tests are supposed to check if the loop exited via a break or not.
However the tests are wrong because if we did not exit via a break then
"p" is not a valid pointer. In that case, it's the equivalent of
"if (*(u32 *)sr == *last_key) {". That's going to work most of the time,
but there is a potential for those to be equal.
Fixes: 1593123a6a49 ("tipc: add name table dump to new netlink api")
Fixes: 1a1a143daf84 ("tipc: add publication dump to new netlink api")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/name_table.c')
-rw-r--r-- | net/tipc/name_table.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 01396dd1c899..1d8ba233d047 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c @@ -967,7 +967,7 @@ static int __tipc_nl_add_nametable_publ(struct tipc_nl_msg *msg, list_for_each_entry(p, &sr->all_publ, all_publ) if (p->key == *last_key) break; - if (p->key != *last_key) + if (list_entry_is_head(p, &sr->all_publ, all_publ)) return -EPIPE; } else { p = list_first_entry(&sr->all_publ, |