linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH] apparmor: Remove unnecessary NULL check before kvfree()
@ 2024-10-18 21:45 Thorsten Blum
  0 siblings, 0 replies; 4+ messages in thread
From: Thorsten Blum @ 2024-10-18 21:45 UTC (permalink / raw)
  To: John Johansen, Paul Moore, James Morris, Serge E. Hallyn
  Cc: Thorsten Blum, apparmor, linux-security-module, linux-kernel

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(-)

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);
 	}
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [RESEND PATCH] apparmor: Remove unnecessary NULL check before kvfree()
@ 2024-11-07 11:25 Thorsten Blum
  2024-11-07 17:09 ` John Johansen
  0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Blum @ 2024-11-07 11:25 UTC (permalink / raw)
  To: John Johansen, Paul Moore, James Morris, Serge E. Hallyn
  Cc: Thorsten Blum, apparmor, linux-security-module, linux-kernel

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(-)

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);
 	}
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH] apparmor: Remove unnecessary NULL check before kvfree()
  2024-11-07 11:25 [RESEND PATCH] apparmor: Remove unnecessary NULL check before kvfree() Thorsten Blum
@ 2024-11-07 17:09 ` John Johansen
  2024-11-07 17:24   ` Thorsten Blum
  0 siblings, 1 reply; 4+ messages in thread
From: John Johansen @ 2024-11-07 17:09 UTC (permalink / raw)
  To: Thorsten Blum, Paul Moore, James Morris, Serge E. Hallyn
  Cc: apparmor, linux-security-module, linux-kernel

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);
>   	}


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH] apparmor: Remove unnecessary NULL check before kvfree()
  2024-11-07 17:09 ` John Johansen
@ 2024-11-07 17:24   ` Thorsten Blum
  0 siblings, 0 replies; 4+ messages in thread
From: Thorsten Blum @ 2024-11-07 17:24 UTC (permalink / raw)
  To: John Johansen
  Cc: Paul Moore, James Morris, Serge E. Hallyn, apparmor,
	linux-security-module, linux-kernel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-07 17:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-07 11:25 [RESEND PATCH] apparmor: Remove unnecessary NULL check before kvfree() Thorsten Blum
2024-11-07 17:09 ` John Johansen
2024-11-07 17:24   ` Thorsten Blum
  -- strict thread matches above, loose matches on Subject: below --
2024-10-18 21:45 Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).