summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Johansen <john.johansen@canonical.com>2025-08-04 08:07:52 +0300
committerJohn Johansen <john.johansen@canonical.com>2026-01-29 12:27:54 +0300
commite16eee7895502bc3c07043169940b005d44bba8f (patch)
treee4d923e66d2cab8b77ba6d1b048a00d77eefcfc7
parent74b7105e53e80a4072bd3e1a50be7aa15e3f0a01 (diff)
downloadlinux-e16eee7895502bc3c07043169940b005d44bba8f.tar.xz
apparmor: guard against free routines being called with a NULL
aa_free_data() and free_attachment() don't guard against having a NULL parameter passed to them. Fix this. Reviewed-by: Ryan Lee <ryan.lee@canonical.com> Signed-off-by: John Johansen <john.johansen@canonical.com>
-rw-r--r--security/apparmor/policy.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
index f2cef22ed729..a64cfd24cedc 100644
--- a/security/apparmor/policy.c
+++ b/security/apparmor/policy.c
@@ -232,6 +232,9 @@ static void aa_free_data(void *ptr, void *arg)
{
struct aa_data *data = ptr;
+ if (!ptr)
+ return;
+
kvfree_sensitive(data->data, data->size);
kfree_sensitive(data->key);
kfree_sensitive(data);
@@ -241,6 +244,9 @@ static void free_attachment(struct aa_attachment *attach)
{
int i;
+ if (!attach)
+ return;
+
for (i = 0; i < attach->xattr_count; i++)
kfree_sensitive(attach->xattrs[i]);
kfree_sensitive(attach->xattrs);