Skip to contentSkip to conversation

apparmor: Remove unnecessary NULL check before kvfree()

PATCH RESEND In review Thorsten Blum 2 participants 3 messages Nov 7, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 apparmor: Remove unnecessary NULL check before kvfree()

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

---
 security/apparmor/policy.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
security/apparmor/policy.c +1 -2
index 14df15e35695..ce1c96cb2aed 100644
@@ -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);
 	}
Signature · 1 line
2.47.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Thorsten Blum

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

sorry I am way way behind on this. I am going to work through the backlog on this list today.

I have pulled this in to my local tree, and will push it up in a few hours once I been through the other patches and testing.

Quoted 18 lines
---
  security/apparmor/policy.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
security/apparmor/policy.c +1 -2
index 14df15e35695..ce1c96cb2aed 100644
@@ -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);
  	}
#2 lore raw
Quoted 8 lines · John Johansen
Quoted 6 lines · Thorsten Blum

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

Quoted 7 lines

sorry I am way way behind on this. I am going to work through the backlog on this list today.

I have pulled this in to my local tree, and will push it up in a few hours once I been through the other patches and testing.

No worries and thanks for the update.

Thorsten