Skip to content

Commit a1f8fec

Browse files
Dan Carpenterdavem330
authored andcommitted
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: 1593123 ("tipc: add name table dump to new netlink api") Fixes: 1a1a143 ("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>
1 parent de7b2ef commit a1f8fec

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

net/tipc/name_table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ static int __tipc_nl_add_nametable_publ(struct tipc_nl_msg *msg,
967967
list_for_each_entry(p, &sr->all_publ, all_publ)
968968
if (p->key == *last_key)
969969
break;
970-
if (p->key != *last_key)
970+
if (list_entry_is_head(p, &sr->all_publ, all_publ))
971971
return -EPIPE;
972972
} else {
973973
p = list_first_entry(&sr->all_publ,

net/tipc/socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3749,7 +3749,7 @@ static int __tipc_nl_list_sk_publ(struct sk_buff *skb,
37493749
if (p->key == *last_publ)
37503750
break;
37513751
}
3752-
if (p->key != *last_publ) {
3752+
if (list_entry_is_head(p, &tsk->publications, binding_sock)) {
37533753
/* We never set seq or call nl_dump_check_consistent()
37543754
* this means that setting prev_seq here will cause the
37553755
* consistence check to fail in the netlink callback

0 commit comments

Comments
 (0)