mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-29 09:13:38 +00:00
samples/bpf: Fix a resource leak
The opened file should be closed in show_sockopts(), otherwise resource leak will occur that this problem was discovered by reading code Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20241010014126.2573-1-zhujun2@cmss.chinamobile.com
This commit is contained in:
parent
c6ca31981b
commit
f3ef53174b
@ -178,8 +178,10 @@ static int show_sockopts(int family)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_bind_to_device(sd, name, sizeof(name)) < 0)
|
if (get_bind_to_device(sd, name, sizeof(name)) < 0) {
|
||||||
|
close(sd);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
mark = get_somark(sd);
|
mark = get_somark(sd);
|
||||||
prio = get_priority(sd);
|
prio = get_priority(sd);
|
||||||
|
Loading…
Reference in New Issue
Block a user