]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bpf: Call the missed kfree() when there is no special field in btf
authorHou Tao <houtao1@huawei.com>
Thu, 12 Sep 2024 01:28:45 +0000 (09:28 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 13 Sep 2024 23:51:08 +0000 (16:51 -0700)
commit986deb297d48ae7039ab975f00c14f0bfe069125
treefdc8947b1da054ae106965185c1506309172d4ff
parent87e9675a0dfd0bf4a36550e4a0e673038ec67aee
bpf: Call the missed kfree() when there is no special field in btf

Call the missed kfree() in btf_parse_struct_metas() when there is no
special field in btf, otherwise will get the following kmemleak report:

unreferenced object 0xffff888101033620 (size 8):
  comm "test_progs", pid 604, jiffies 4295127011
  ......
  backtrace (crc e77dc444):
    [<00000000186f90f3>] kmemleak_alloc+0x4b/0x80
    [<00000000ac8e9c4d>] __kmalloc_cache_noprof+0x2a1/0x310
    [<00000000d99d68d6>] btf_new_fd+0x72d/0xe90
    [<00000000f010b7f8>] __sys_bpf+0xec3/0x2410
    [<00000000e077ed6f>] __x64_sys_bpf+0x1f/0x30
    [<00000000a12f9e55>] x64_sys_call+0x199/0x9f0
    [<00000000f3029ea6>] do_syscall_64+0x3b/0xc0
    [<000000005640913a>] entry_SYSCALL_64_after_hwframe+0x4b/0x53

Fixes: 7a851ecb1806 ("bpf: Search for kptrs in prog BTF structs")
Signed-off-by: Hou Tao <houtao1@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20240912012845.3458483-3-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/btf.c