lkml.org 
[lkml]   [2021]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.15 501/917] libbpf: Fix memory leak in btf__dedup()
    Date
    From: Mauricio Vásquez <mauricio@kinvolk.io>

    [ Upstream commit 1000298c76830bc291358e98e8fa5baa3baa9b3a ]

    Free btf_dedup if btf_ensure_modifiable() returns error.

    Fixes: 919d2b1dbb07 ("libbpf: Allow modification of BTF and add btf__add_str API")
    Signed-off-by: Mauricio Vásquez <mauricio@kinvolk.io>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211022202035.48868-1-mauricio@kinvolk.io
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    tools/lib/bpf/btf.c | 6 ++++--
    1 file changed, 4 insertions(+), 2 deletions(-)

    diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
    index 77dc24d58302d..bf8c8676d68e5 100644
    --- a/tools/lib/bpf/btf.c
    +++ b/tools/lib/bpf/btf.c
    @@ -2914,8 +2914,10 @@ int btf__dedup(struct btf *btf, struct btf_ext *btf_ext,
    return libbpf_err(-EINVAL);
    }

    - if (btf_ensure_modifiable(btf))
    - return libbpf_err(-ENOMEM);
    + if (btf_ensure_modifiable(btf)) {
    + err = -ENOMEM;
    + goto done;
    + }

    err = btf_dedup_prep(d);
    if (err) {
    --
    2.33.0


    \
     
     \ /
      Last update: 2021-11-16 00:43    [W:2.393 / U:0.152 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site