BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next] libbpf: fix memleak in libbpf_netlink_recv()
@ 2022-02-17  7:39 Andrii Nakryiko
  2022-02-17 13:05 ` Toke Høiland-Jørgensen
  2022-02-17 15:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2022-02-17  7:39 UTC (permalink / raw)
  To: bpf, ast, daniel; +Cc: andrii, kernel-team, Toke Høiland-Jørgensen

Ensure that libbpf_netlink_recv() frees dynamically allocated buffer in
all code paths.

Cc: Toke Høiland-Jørgensen <toke@redhat.com>
Fixes: 9c3de619e13e ("libbpf: Use dynamically allocated buffer when receiving netlink messages")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 tools/lib/bpf/netlink.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/lib/bpf/netlink.c b/tools/lib/bpf/netlink.c
index a598061f6fea..cbc8967d5402 100644
--- a/tools/lib/bpf/netlink.c
+++ b/tools/lib/bpf/netlink.c
@@ -176,7 +176,8 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq,
 				libbpf_nla_dump_errormsg(nh);
 				goto done;
 			case NLMSG_DONE:
-				return 0;
+				ret = 0;
+				goto done;
 			default:
 				break;
 			}
@@ -188,9 +189,10 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq,
 				case NL_NEXT:
 					goto start;
 				case NL_DONE:
-					return 0;
+					ret = 0;
+					goto done;
 				default:
-					return ret;
+					goto done;
 				}
 			}
 		}
-- 
2.30.2


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

* Re: [PATCH bpf-next] libbpf: fix memleak in libbpf_netlink_recv()
  2022-02-17  7:39 [PATCH bpf-next] libbpf: fix memleak in libbpf_netlink_recv() Andrii Nakryiko
@ 2022-02-17 13:05 ` Toke Høiland-Jørgensen
  2022-02-17 15:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Toke Høiland-Jørgensen @ 2022-02-17 13:05 UTC (permalink / raw)
  To: Andrii Nakryiko, bpf, ast, daniel; +Cc: andrii, kernel-team

Andrii Nakryiko <andrii@kernel.org> writes:

> Ensure that libbpf_netlink_recv() frees dynamically allocated buffer in
> all code paths.
>
> Cc: Toke Høiland-Jørgensen <toke@redhat.com>
> Fixes: 9c3de619e13e ("libbpf: Use dynamically allocated buffer when receiving netlink messages")
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

Oops! I saw there were already 'goto done' labels in that block of code
so assumed it was all fine and didn't look closer. Thank you for the
fix!

-Toke


Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>


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

* Re: [PATCH bpf-next] libbpf: fix memleak in libbpf_netlink_recv()
  2022-02-17  7:39 [PATCH bpf-next] libbpf: fix memleak in libbpf_netlink_recv() Andrii Nakryiko
  2022-02-17 13:05 ` Toke Høiland-Jørgensen
@ 2022-02-17 15:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-17 15:20 UTC (permalink / raw)
  To: Andrii Nakryiko; +Cc: bpf, ast, daniel, kernel-team, toke

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Wed, 16 Feb 2022 23:39:58 -0800 you wrote:
> Ensure that libbpf_netlink_recv() frees dynamically allocated buffer in
> all code paths.
> 
> Cc: Toke Høiland-Jørgensen <toke@redhat.com>
> Fixes: 9c3de619e13e ("libbpf: Use dynamically allocated buffer when receiving netlink messages")
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> 
> [...]

Here is the summary with links:
  - [bpf-next] libbpf: fix memleak in libbpf_netlink_recv()
    https://git.kernel.org/bpf/bpf-next/c/1b8c924a0593

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] 3+ messages in thread

end of thread, other threads:[~2022-02-17 15:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-17  7:39 [PATCH bpf-next] libbpf: fix memleak in libbpf_netlink_recv() Andrii Nakryiko
2022-02-17 13:05 ` Toke Høiland-Jørgensen
2022-02-17 15:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox