]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bpf: fix memleak in restrict_fs_bpf
authorJulia Kartseva <hex@fb.com>
Tue, 23 Nov 2021 23:38:11 +0000 (15:38 -0800)
committerLennart Poettering <lennart@poettering.net>
Wed, 24 Nov 2021 08:37:33 +0000 (09:37 +0100)
Memory allocated in bpf skeleton is not freed. Wrap ptr in _cleanup_.

Fixes: #21471
src/core/bpf-lsm.c

index ed35cad91dd60628113657010651f49117a2d1d8..8af2da0288d254d11c493c3fc84da621a366d36a 100644 (file)
@@ -52,7 +52,7 @@ static bool bpf_can_link_lsm_program(struct bpf_program *prog) {
 }
 
 static int prepare_restrict_fs_bpf(struct restrict_fs_bpf **ret_obj) {
-        struct restrict_fs_bpf *obj = 0;
+        _cleanup_(restrict_fs_bpf_freep) struct restrict_fs_bpf *obj = NULL;
         _cleanup_close_ int inner_map_fd = -1;
         int r;