]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
apparmor: guard against free routines being called with a NULL
authorJohn Johansen <john.johansen@canonical.com>
Mon, 4 Aug 2025 05:07:52 +0000 (22:07 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Thu, 29 Jan 2026 09:27:54 +0000 (01:27 -0800)
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>
security/apparmor/policy.c

index f2cef22ed72930c857d78561a2722e195315affb..a64cfd24cedc4b8313fc0a01a52f333b79d6b009 100644 (file)
@@ -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);