mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:44:45 +01:00
selftests/bpf: Free bpf_object in test_sysctl
ASAN reported a resource leak due to the bpf_object not being tracked in test_sysctl. Add obj field to struct sysctl_test to properly clean it up. Acked-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Link: https://lore.kernel.org/r/20260223190736.649171-17-ihor.solodrai@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
71dca2950f
commit
2bb270a0ac
1 changed files with 3 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ struct sysctl_test {
|
|||
OP_EPERM,
|
||||
SUCCESS,
|
||||
} result;
|
||||
struct bpf_object *obj;
|
||||
};
|
||||
|
||||
static struct sysctl_test tests[] = {
|
||||
|
|
@ -1471,6 +1472,7 @@ static int load_sysctl_prog_file(struct sysctl_test *test)
|
|||
return -1;
|
||||
}
|
||||
|
||||
test->obj = obj;
|
||||
return prog_fd;
|
||||
}
|
||||
|
||||
|
|
@ -1573,6 +1575,7 @@ out:
|
|||
/* Detaching w/o checking return code: best effort attempt. */
|
||||
if (progfd != -1)
|
||||
bpf_prog_detach(cgfd, atype);
|
||||
bpf_object__close(test->obj);
|
||||
close(progfd);
|
||||
printf("[%s]\n", err ? "FAIL" : "PASS");
|
||||
return err;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue