From: Anton Moryakov Date: Sat, 19 Jul 2025 10:42:12 +0000 (+0300) Subject: misc: fix memory leak in ifstat.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b09a1b053a2f4dbba6128b3fb703e008819c791;p=thirdparty%2Fiproute2.git misc: fix memory leak in ifstat.c A memory leak was detected by the static analyzer SVACE in the function get_nlmsg_extended(). The issue occurred when parsing extended interface statistics failed due to a missing nested attribute. In this case, memory allocated for 'n->name' via strdup() was not freed before returning, resulting in a leak. The fix adds an explicit 'free(n->name)' call before freeing the containing structure in the error path. Reported-by: SVACE static analyzer Signed-off-by: Anton Moryakov Signed-off-by: David Ahern --- diff --git a/misc/ifstat.c b/misc/ifstat.c index faebe938..a47d0b16 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -152,6 +152,7 @@ static int get_nlmsg_extended(struct nlmsghdr *m, void *arg) attr = parse_rtattr_one_nested(sub_type, tb[filter_type]); if (attr == NULL) { + free(n->name); free(n); return 0; }