summaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2022-02-22 16:43:12 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-03-02 11:38:11 +0100
commit33f724448e055b615301c039df5638cce458d6ac (patch)
treefc4228613ffe6b152113374f92920afacb2d72da /net/tipc
parent1f4ae0f158dafa74133108bfa07b8053eb2a7898 (diff)
downloadlinux-stable-33f724448e055b615301c039df5638cce458d6ac.tar.gz
linux-stable-33f724448e055b615301c039df5638cce458d6ac.tar.bz2
linux-stable-33f724448e055b615301c039df5638cce458d6ac.zip
tipc: Fix end of loop tests for list_for_each_entry()
commit a1f8fec4dac8bc7b172b2bdbd881e015261a6322 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/name_table.c2
-rw-r--r--net/tipc/socket.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 89993afe0fbd..059ffb8b466a 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -812,7 +812,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,
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 848ae6dcbd82..6c18b4565ab5 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -3487,7 +3487,7 @@ static int __tipc_nl_list_sk_publ(struct sk_buff *skb,
if (p->key == *last_publ)
break;
}
- if (p->key != *last_publ) {
+ if (list_entry_is_head(p, &tsk->publications, binding_sock)) {
/* We never set seq or call nl_dump_check_consistent()
* this means that setting prev_seq here will cause the
* consistence check to fail in the netlink callback