projects
/
linux-block.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c6ca319
)
samples/bpf: Fix a resource leak
author
Zhu Jun
<zhujun2@cmss.chinamobile.com>
Thu, 10 Oct 2024 01:41:26 +0000
(18:41 -0700)
committer
Andrii Nakryiko
<andrii@kernel.org>
Fri, 11 Oct 2024 02:13:47 +0000
(19:13 -0700)
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
samples/bpf/test_cgrp2_sock.c
patch
|
blob
|
blame
|
history
diff --git
a/samples/bpf/test_cgrp2_sock.c
b/samples/bpf/test_cgrp2_sock.c
index a0811df888f4530465af7cae9e4eaf7a0512e797..8ca2a445ffa15542ded0a931dc9a4c08c948f37b 100644
(file)
--- a/
samples/bpf/test_cgrp2_sock.c
+++ b/
samples/bpf/test_cgrp2_sock.c
@@
-178,8
+178,10
@@
static int show_sockopts(int family)
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;
+ }
mark = get_somark(sd);
prio = get_priority(sd);