diff mbox series

[RESEND] apparmor: Remove unnecessary NULL check before kvfree()

Message ID 20241107112526.2312-2-thorsten.blum@linux.dev (mailing list archive)
State New
Headers show
Series [RESEND] apparmor: Remove unnecessary NULL check before kvfree() | expand

Commit Message

Thorsten Blum Nov. 7, 2024, 11:25 a.m. UTC
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>
---
 security/apparmor/policy.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

John Johansen Nov. 7, 2024, 5:09 p.m. UTC | #1
On 11/7/24 03:25, Thorsten Blum wrote:
> 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>

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

Acked-by: John Johansen <john.johansen@canonical.com>

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.

> ---
>   security/apparmor/policy.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
> index 14df15e35695..ce1c96cb2aed 100644
> --- a/security/apparmor/policy.c
> +++ b/security/apparmor/policy.c
> @@ -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);
>   	}
Thorsten Blum Nov. 7, 2024, 5:24 p.m. UTC | #2
On 7. Nov 2024, at 18:09, John Johansen wrote:
> On 11/7/24 03:25, Thorsten Blum wrote:
>> 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>
> 
> sorry I am way way behind on this. I am going to work through the backlog
> on this list today.
> 
> Acked-by: John Johansen <john.johansen@canonical.com>
> 
> 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
diff mbox series

Patch

diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
index 14df15e35695..ce1c96cb2aed 100644
--- a/security/apparmor/policy.c
+++ b/security/apparmor/policy.c
@@ -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);
 	}