Skip to contentSkip to conversation

fs: hfsplus: remove redundant NULL check before kfree()

PATCH In review [email protected] 2 participants 8 messages Jul 3 – Jul 28 1 message not in the archive

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

PATCH 1/1 fs: hfsplus: remove redundant NULL check before kfree()

From: Mohammad Shahid <[email protected]>

kfree() safely handles NULL pointers, so the explicit NULL check before calling kfree() is unnecessary.

This issue was reported by ifnullfree.cocci.

---
 fs/hfsplus/unicode_test.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/hfsplus/unicode_test.c +1 -2
index 83737c9bafa0..7f6b2a3c69d9 100644
@@ -39,8 +39,7 @@ static struct test_mock_string_env *setup_mock_str_env(u32 buf_size)
 
 static void free_mock_str_env(struct test_mock_string_env *env)
 {
-	if (env->buf)
-		kfree(env->buf);
+	kfree(env->buf);
 	kfree(env);
 }
 
Signature · 1 line
2.43.0
#1 lore raw

Hi,

Gentle ping on this patch.

Could you please take a look when time permits?

Thanks!

Mohammad Shahid

#2 lore raw
Quoted 6 lines · On Fri, 2026-07-24 at 18:10 +0530, [email protected] wrote:

Hi,

Gentle ping on this patch.

Could you please take a look when time permits?

Somehow, b4 cannot see your patch and I cannot find your initial path in my email client. Could you please resend your patch? Something was wrong from the beginning.

Thanks,
Slava.

#3 lore raw

Hi Slava,

Thanks for letting me know.

Resending the patch as requested.

Thanks!

Mohammad Shahid

#4 lore raw

PATCH 1/1 fs: hfsplus: remove redundant NULL check before kfree()

From: Mohammad Shahid <[email protected]>

kfree() safely handles NULL pointers, so the explicit NULL check before calling kfree() is unnecessary.

This issue was reported by ifnullfree.cocci.

---
 fs/hfsplus/unicode_test.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/hfsplus/unicode_test.c +1 -2
index 83737c9bafa0..7f6b2a3c69d9 100644
@@ -39,8 +39,7 @@ static struct test_mock_string_env *setup_mock_str_env(u32 buf_size)
 
 static void free_mock_str_env(struct test_mock_string_env *env)
 {
-	if (env->buf)
-		kfree(env->buf);
+	kfree(env->buf);
 	kfree(env);
 }
 
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#5 lore raw
Quoted 24 lines · On Sun, 2026-07-26 at 12:12 +0530, [email protected] wrote:

From: Mohammad Shahid <[email protected]>

kfree() safely handles NULL pointers, so the explicit NULL check before calling kfree() is unnecessary.

This issue was reported by ifnullfree.cocci.

---
 fs/hfsplus/unicode_test.c | 3 +--

 1 file changed, 1 insertion(+), 2 deletions(-)
fs/hfsplus/unicode_test.c +0 -0
index 83737c9bafa0..7f6b2a3c69d9 100644
@@ -39,8 +39,7 @@ static struct test_mock_string_env
 *setup_mock_str_env(u32 buf_size)


 static void free_mock_str_env(struct test_mock_string_env *env) {

fs/hfsplus/unicode_test.c +1 -2
-	if (env->buf)
-		kfree(env->buf);
+	kfree(env->buf);
Quoted 3 lines

  kfree(env);
 }

Makes sense.

Thanks,
Slava.

maintainer Applied
#6 lore raw
Quoted 31 lines · Viacheslav Dubeyko
Quoted 24 lines · On Sun, 2026-07-26 at 12:12 +0530, [email protected] wrote:

From: Mohammad Shahid <[email protected]>

kfree() safely handles NULL pointers, so the explicit NULL check before calling kfree() is unnecessary.

This issue was reported by ifnullfree.cocci.

---
 fs/hfsplus/unicode_test.c | 3 +--

 1 file changed, 1 insertion(+), 2 deletions(-)
fs/hfsplus/unicode_test.c +0 -0
index 83737c9bafa0..7f6b2a3c69d9 100644
@@ -39,8 +39,7 @@ static struct test_mock_string_env
 *setup_mock_str_env(u32 buf_size)


 static void free_mock_str_env(struct test_mock_string_env *env) {

fs/hfsplus/unicode_test.c +1 -2
-	if (env->buf)
-		kfree(env->buf);
+	kfree(env->buf);
Quoted 3 lines

  kfree(env);
 }

Makes sense.

Quoted 2 lines

Applied.

Thanks,
Slava.

A message that is not in the archive (sent off-list or not yet received): CACRLeC5agyqVnvjdziV5C_Z+y6NPvXg1Nyv2g_mmK2D1QbsfYQ@mail.gmail.com

maintainer Reviewed-by
#8 lore raw
Quoted 5 lines · md shahid

Hi,

Gentle ping on this patch.

Could someone please review it when time permits?

Sorry, I've missed this patch because of "fs: hfsplus" title.

Quoted 24 lines

Thanks!
Shahid.

Quoted 19 lines · On Fri, Jul 3, 2026 at 3:53 PM <[email protected]> wrote:

From: Mohammad Shahid <[email protected]>

kfree() safely handles NULL pointers, so the explicit NULL check before calling kfree() is unnecessary.

This issue was reported by ifnullfree.cocci.

---
 fs/hfsplus/unicode_test.c | 3 +--

 1 file changed, 1 insertion(+), 2 deletions(-)
fs/hfsplus/unicode_test.c +0 -0
index 83737c9bafa0..7f6b2a3c69d9 100644
@@ -39,8 +39,7 @@ static struct test_mock_string_env
 *setup_mock_str_env(u32 buf_size)
 
Quoted 8 lines

fs/hfsplus/unicode_test.c static struct test_mock_string_env *setup_mock_str_env(u32 buf_size) · line 44

Quoted 8 lines
fs/hfsplus/unicode_test.c +1 -2
  static void free_mock_str_env(struct test_mock_string_env *env)
  {
-       if (env->buf)
-               kfree(env->buf);
+       kfree(env->buf);
         kfree(env);
  }

Makes sense.

Thanks,
Slava.