[PATCH bpf-next] samples/bpf: Don't use uninitialized cg2 variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When the setup_cgroup_environment function returns false, we enter a
cleanup path that uses the cg2 variable, which, at this point, is not
initialized.
This change fixes the issue by introducing a new error label that does
not perform the close operation which uses said variable on this path.

Signed-off-by: Daniel Müller <deso@xxxxxxxxxx>
---
 samples/bpf/test_current_task_under_cgroup_user.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/samples/bpf/test_current_task_under_cgroup_user.c b/samples/bpf/test_current_task_under_cgroup_user.c
index ac251a..04a37f 100644
--- a/samples/bpf/test_current_task_under_cgroup_user.c
+++ b/samples/bpf/test_current_task_under_cgroup_user.c
@@ -55,7 +55,7 @@ int main(int argc, char **argv)
 	}
 
 	if (setup_cgroup_environment())
-		goto err;
+		goto err_cgroup;
 
 	cg2 = create_and_get_cgroup(CGROUP_PATH);
 
@@ -104,6 +104,7 @@ int main(int argc, char **argv)
 
 err:
 	close(cg2);
+err_cgroup:
 	cleanup_cgroup_environment();
 
 cleanup:
-- 
2.30.2




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux