From 90f175d82dabfa564122e98949f5abb5590d89d1 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Mon, 11 May 2026 20:03:20 +1000 Subject: packet, clang-tidy: Packet pool buffers are not NULL struct pool always needs a non-NULL buf field: it points either to the actual memory used to store packets, or for vhost-user to the vhost user memory structure which will contain the packets. We set this pointer when we initialise the pool. However, clang-tidy (as of 22.1.4, at least) doesn't realise this in packet_check_range(), causing UB warnings due to the subtraction of ptr and p->buf. Clue it in with an assert(). Signed-off-by: David Gibson Reviewed-by: Laurent Vivier Signed-off-by: Stefano Brivio --- packet.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packet.c b/packet.c index 1cb74b7..7a347be 100644 --- a/packet.c +++ b/packet.c @@ -51,6 +51,8 @@ static int packet_check_range(const struct pool *p, const char *ptr, size_t len, { struct vdev_memory *memory; + assert(p->buf); + if (len > PACKET_MAX_LEN) { debug("packet range length %zu (max %zu), %s:%i", len, PACKET_MAX_LEN, func, line); -- cgit v1.2.3