aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2026-05-11 20:03:20 +1000
committerStefano Brivio <sbrivio@redhat.com>2026-05-12 00:04:06 +0200
commit90f175d82dabfa564122e98949f5abb5590d89d1 (patch)
treed8b725afc35c9a8a82998215c83294e686f828b0
parent7bafe7163ab0bfafc3d90dcba06c1b045b57a285 (diff)
downloadpasst-90f175d82dabfa564122e98949f5abb5590d89d1.tar
passt-90f175d82dabfa564122e98949f5abb5590d89d1.tar.gz
passt-90f175d82dabfa564122e98949f5abb5590d89d1.tar.bz2
passt-90f175d82dabfa564122e98949f5abb5590d89d1.tar.lz
passt-90f175d82dabfa564122e98949f5abb5590d89d1.tar.xz
passt-90f175d82dabfa564122e98949f5abb5590d89d1.tar.zst
passt-90f175d82dabfa564122e98949f5abb5590d89d1.zip
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 <david@gibson.dropbear.id.au> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--packet.c2
1 files changed, 2 insertions, 0 deletions
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);