]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
netlink: fix netlink_diag_dump() return value
authorEric Dumazet <edumazet@google.com>
Thu, 22 Feb 2024 10:50:12 +0000 (10:50 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 26 Feb 2024 11:46:12 +0000 (11:46 +0000)
__netlink_diag_dump() returns 1 if the dump is not complete,
zero if no error occurred.

If err variable is zero, this means the dump is complete:
We should not return skb->len in this case, but 0.

This allows NLMSG_DONE to be appended to the skb.
User space does not have to call us again only to get NLMSG_DONE.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netlink/diag.c

index e12c90d5f6ad29446ea1990c88c19bcb0ee856c3..61981e01fd6ff189dcb46a06a4d265cf6029b840 100644 (file)
@@ -207,7 +207,7 @@ static int netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
                err = __netlink_diag_dump(skb, cb, req->sdiag_protocol, s_num);
        }
 
-       return err < 0 ? err : skb->len;
+       return err <= 0 ? err : skb->len;
 }
 
 static int netlink_diag_dump_done(struct netlink_callback *cb)