All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 iproute2-next] misc: fix memory leak in ifstat.c
@ 2025-07-19 10:42 Anton Moryakov
  2025-07-29 23:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Anton Moryakov @ 2025-07-19 10:42 UTC (permalink / raw)
  To: netdev; +Cc: Anton Moryakov

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 <ant.v.moryakov@gmail.com>
---
 misc/ifstat.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/misc/ifstat.c b/misc/ifstat.c
index 4ce5ca8a..3de20c63 100644
--- a/misc/ifstat.c
+++ b/misc/ifstat.c
@@ -138,6 +138,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;
 		}
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH V2 iproute2-next] misc: fix memory leak in ifstat.c
  2025-07-19 10:42 [PATCH V2 iproute2-next] misc: fix memory leak in ifstat.c Anton Moryakov
@ 2025-07-29 23:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-29 23:30 UTC (permalink / raw)
  To: Anton Moryakov; +Cc: netdev

Hello:

This patch was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:

On Sat, 19 Jul 2025 13:42:12 +0300 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [V2,iproute2-next] misc: fix memory leak in ifstat.c
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=0b09a1b053a2

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-29 23:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-19 10:42 [PATCH V2 iproute2-next] misc: fix memory leak in ifstat.c Anton Moryakov
2025-07-29 23:30 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.