Skip to contentSkip to conversation

dm: crash dump: remove redundant NULL check before kvfree()

PATCH In review [email protected] 3 participants 4 messages Jul 3

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

PATCH 1/1 dm: crash dump: remove redundant NULL check before kvfree()

From: Mohammad Shahid <[email protected]>

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

This issue was reported by ifnullfree.cocci.

---
 kernel/crash_dump_dm_crypt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/crash_dump_dm_crypt.c +1 -2
index cb875ddb6ba6..cf4d41fd4d5e 100644
@@ -364,8 +364,7 @@ static int build_keys_header(void)
 	struct config_key *key;
 	int i, r;
 
-	if (keys_header != NULL)
-		kvfree(keys_header);
+	kvfree(keys_header);
 
 	keys_header = kzalloc(get_keys_header_size(key_count), GFP_KERNEL);
 	if (!keys_header)
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Fri, Jul 03 2026, [email protected] wrote:

From: Mohammad Shahid <[email protected]>

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

This issue was reported by ifnullfree.cocci.

BTW, Sashiko [0] pointed out a bunch of problems in the surrounding code, and they seem to look legit. If you're interested, help in fixing them would be much appreciated.

[0] https://sashiko.dev/#/patchset/[email protected]

[...]

Signature · 2 lines
Regards,
Pratyush Yadav
#2 lore raw
Quoted 4 lines · Pratyush Yadav
Quoted 2 lines · On Fri, Jul 03 2026, [email protected] wrote:

From: Mohammad Shahid <[email protected]>

Quoted 8 lines
Quoted 6 lines

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

This issue was reported by ifnullfree.cocci.

Hi Pratyush,

Thanks for reviewing this patch!

Quoted 6 lines

BTW, Sashiko [0] pointed out a bunch of problems in the surrounding code, and they seem to look legit. If you're interested, help in fixing them would be much appreciated.

[0] https://sashiko.dev/#/patchset/[email protected]

I'll send a new version of
https://lore.kernel.org/kexec/[email protected]/
soon which can address Sashiko's feedback scrutinized by Sourabh.

Quoted 7 lines

[...]

Signature · 2 lines
Regards,
Pratyush Yadav
Signature · 2 lines
Best regards,
Coiby
maintainer
#3 lore raw
Quoted 23 lines · Coiby Xu
Quoted 4 lines · Pratyush Yadav
Quoted 2 lines · On Fri, Jul 03 2026, [email protected] wrote:

From: Mohammad Shahid <[email protected]>

Quoted 8 lines
Quoted 6 lines

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

This issue was reported by ifnullfree.cocci.

Hi Pratyush,

Thanks for reviewing this patch!

Quoted 5 lines

BTW, Sashiko [0] pointed out a bunch of problems in the surrounding code, and they seem to look legit. If you're interested, help in fixing them would be much appreciated.

Quoted 5 lines
Quoted 1 line

[0] https://sashiko.dev/#/patchset/[email protected]

I'll send a new version of
https://lore.kernel.org/kexec/[email protected]/
soon which can address Sashiko's feedback scrutinized by Sourabh.

Oh, great. Thanks!

Signature · 2 lines
Regards,
Pratyush Yadav