From: Zygmunt Krynicki Date: Sat, 2 May 2026 11:21:33 +0000 (+0200) Subject: apparmor: aa_label_alloc use aa_label_free on alloc failure X-Git-Tag: v7.2-rc1~43^2~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=654fe7505dc6889724d4094fa64f89991afabfc3;p=thirdparty%2Fkernel%2Flinux.git apparmor: aa_label_alloc use aa_label_free on alloc failure aa_label_alloc() allocates a secid before allocating or taking the label proxy. If the later proxy step fails, the error path only freed the label memory, leaking any resources initialized by aa_label_init(). Use aa_label_free() on the failure path so partially initialized labels release their secid and other label resources before the backing memory is freed. Fixes: f1bd904175e81 ("apparmor: add the base fns() for domain labels") Signed-off-by: Zygmunt Krynicki Signed-off-by: John Johansen --- diff --git a/security/apparmor/label.c b/security/apparmor/label.c index a8850d118c9cc..c60244ed96db0 100644 --- a/security/apparmor/label.c +++ b/security/apparmor/label.c @@ -458,7 +458,7 @@ struct aa_label *aa_label_alloc(int size, struct aa_proxy *proxy, gfp_t gfp) return new; fail: - kfree(new); + aa_label_free(new); return NULL; }