Skip to contentSkip to conversation

futex: remove unnecessary NULL check before kvfree()

PATCH Applied Vasileios Almpanis 3 participants 3 messages Jun 30 – Jul 5 Futex

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 futex: remove unnecessary NULL check before kvfree()

NULL check before kvfree() is unnecessary and triggers a Coccinelle warning, since kvfree() handles NULL arguments internally.

Reported by ifnullfree.cocci Coccinelle semantic patch script.

---
 kernel/futex/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/futex/core.c +1 -2
index 179b26e9c934..233b926f5624 100644
@@ -1746,8 +1746,7 @@ void futex_hash_free(struct mm_struct *mm)
 	free_percpu(mm->futex.phash.ref);
 	kvfree(mm->futex.phash.hash_new);
 	fph = rcu_dereference_raw(mm->futex.phash.hash);
-	if (fph)
-		kvfree(fph);
+	kvfree(fph);
 }
 
 static bool futex_pivot_pending(struct mm_struct *mm)
Signature · 1 line
2.47.3
#2 lore raw

[tip: locking/futex] futex: Remove unnecessary NULL check before kvfree()

In reply to Vasileios Almpanis
The following commit has been merged into the locking/futex branch of tip:

The following commit has been merged into the locking/futex branch of tip:

Commit-ID:     4903ab0c83f033424879ba7435668f9ebe14f641
Gitweb:        https://git.kernel.org/tip/4903ab0c83f033424879ba7435668f9ebe14f641
Author:        Vasileios Almpanis <[email protected]>
AuthorDate:    Tue, 30 Jun 2026 15:35:21 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Sun, 05 Jul 2026 14:50:19 +02:00

futex: Remove unnecessary NULL check before kvfree()

The NULL check before kvfree() is unnecessary and triggers a Coccinelle warning, since kvfree() handles NULL arguments internally.

Reported by ifnullfree.cocci Coccinelle semantic patch script.

---
 kernel/futex/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/futex/core.c +1 -2
index 179b26e..233b926 100644
@@ -1746,8 +1746,7 @@ void futex_hash_free(struct mm_struct *mm)
 	free_percpu(mm->futex.phash.ref);
 	kvfree(mm->futex.phash.hash_new);
 	fph = rcu_dereference_raw(mm->futex.phash.hash);
-	if (fph)
-		kvfree(fph);
+	kvfree(fph);
 }
 
 static bool futex_pivot_pending(struct mm_struct *mm)