]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
apparmor: Remove unnecessary NULL check before kvfree()
authorThorsten Blum <thorsten.blum@linux.dev>
Thu, 7 Nov 2024 11:25:27 +0000 (12:25 +0100)
committerJohn Johansen <john.johansen@canonical.com>
Wed, 27 Nov 2024 03:21:05 +0000 (19:21 -0800)
Since kvfree() already checks if its argument is NULL, an additional
check before calling kvfree() is unnecessary and can be removed.

Remove it and the following Coccinelle/coccicheck warning reported by
ifnullfree.cocci:

  WARNING: NULL check before some freeing functions is not needed

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/policy.c

index 105706abf281b2ea4e76c5d5b5013d6f341035dc..c5446a1d20bfdfc5c5b6d733cd89cf5858e8942f 100644 (file)
@@ -103,8 +103,7 @@ static void aa_free_pdb(struct aa_policydb *pdb)
 {
        if (pdb) {
                aa_put_dfa(pdb->dfa);
-               if (pdb->perms)
-                       kvfree(pdb->perms);
+               kvfree(pdb->perms);
                aa_free_str_table(&pdb->trans);
                kfree(pdb);
        }