pr_out_dev_net_vstats() appended " %lu " to the driver-supplied vendor attribute name and used it as the printf format, so a '%' in the name was taken as a conversion, and names over MAX_KEY_LEN aborted the rest of the dump. Pass the name as a string argument with a literal format, which drops the length limit, and use PRIu64 since uint64_t is not unsigned long on 32-bit. Fixes: 6f97e9c9337b ("vdpa: Add support for reading vdpa device statistics") Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Stephen Hemminger --- vdpa/vdpa.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c index e2b0a5b1..8719a636 100644 --- a/vdpa/vdpa.c +++ b/vdpa/vdpa.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ #include +#include #include #include #include @@ -890,10 +891,6 @@ static int cmd_dev_config(struct vdpa *vdpa, int argc, char **argv) return -ENOENT; } -#define MAX_KEY_LEN 200 -/* 5 bytes for format */ -#define MAX_FMT_LEN (MAX_KEY_LEN + 5 + 1) - static void print_queue_type(struct nlattr *attr, uint16_t max_vqp, uint64_t features) { bool is_ctrl = false; @@ -918,7 +915,6 @@ static void pr_out_dev_net_vstats(const struct nlmsghdr *nlh) { const char *name = NULL; uint64_t features = 0; - char fmt[MAX_FMT_LEN]; uint16_t max_vqp = 0; struct nlattr *attr; uint64_t v64; @@ -936,15 +932,11 @@ static void pr_out_dev_net_vstats(const struct nlmsghdr *nlh) break; case VDPA_ATTR_DEV_VENDOR_ATTR_NAME: name = mnl_attr_get_str(attr); - if (strlen(name) > MAX_KEY_LEN) - return; - - strcpy(fmt, name); - strcat(fmt, " %lu "); break; case VDPA_ATTR_DEV_VENDOR_ATTR_VALUE: v64 = mnl_attr_get_u64(attr); - print_u64(PRINT_ANY, name, fmt, v64); + print_string(PRINT_FP, NULL, "%s ", name); + print_u64(PRINT_ANY, name, "%" PRIu64 " ", v64); break; } } -- 2.53.0