The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] dm: crash dump: remove redundant NULL check before kvfree()
@ 2026-07-03 11:26 mdshahid03
  2026-07-03 12:03 ` Pratyush Yadav
  0 siblings, 1 reply; 4+ messages in thread
From: mdshahid03 @ 2026-07-03 11:26 UTC (permalink / raw)
  To: Andrew Morton, Baoquan He, Mike Rapoport, Pasha Tatashin,
	Pratyush Yadav
  Cc: Dave Young, kexec, linux-kernel, Mohammad Shahid

From: Mohammad Shahid <mdshahid03@gmail.com>

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

This issue was reported by ifnullfree.cocci.

Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
---
 kernel/crash_dump_dm_crypt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/crash_dump_dm_crypt.c b/kernel/crash_dump_dm_crypt.c
index cb875ddb6ba6..cf4d41fd4d5e 100644
--- a/kernel/crash_dump_dm_crypt.c
+++ b/kernel/crash_dump_dm_crypt.c
@@ -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)
-- 
2.43.0


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

end of thread, other threads:[~2026-07-03 13:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03 11:26 [PATCH] dm: crash dump: remove redundant NULL check before kvfree() mdshahid03
2026-07-03 12:03 ` Pratyush Yadav
2026-07-03 13:28   ` Coiby Xu
2026-07-03 13:44     ` Pratyush Yadav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox