Hi sorry for not responding earlier I realised by myself going through the reading submission process and rereading my patch, it was not correct/useful. Cheers. On Fri, 24 Jan 2025 at 02:17, Eduard Zingerman <eddyz87@xxxxxxxxx> wrote: > > On Tue, 2025-01-21 at 16:50 +0000, David CARLIER wrote: > > libbpf.c memory leaks fixes proposal. > > Hi David, > > please take a look at the documentation regarding sending kernel patches: > https://www.kernel.org/doc/html/latest/process/submitting-patches.html > In particular: > - the email should be in plain text > - subject should be present > - the patch itself is a part of the email, not an attachment. > > About the change itself, why do you think there is a resource leak? > Here is a fragment of bpf_program__attach_kprobe_opts: > > link = bpf_program__attach_perf_event_opts(prog, pfd, &pe_opts); > err = libbpf_get_error(link); > if (err) { > - close(pfd); > + bpf_link__destroy(link); > pr_warn("prog '%s': failed to attach to %s '%s+0x%zx': %s\n", > prog->name, retprobe ? "kretprobe" : "kprobe", > func_name, offset, > errstr(err)); > goto err_clean_legacy; > } > > When libbpf_get_error returns a non-zero value the `link` > is either an error value or null, so bpf_link__destroy > has nothing to work with.