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

* Re: [PATCH] dm: crash dump: remove redundant NULL check before kvfree()
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Pratyush Yadav @ 2026-07-03 12:03 UTC (permalink / raw)
  To: mdshahid03
  Cc: Andrew Morton, Baoquan He, Mike Rapoport, Pasha Tatashin,
	Pratyush Yadav, Dave Young, kexec, linux-kernel

On Fri, Jul 03 2026, mdshahid03@gmail.com wrote:

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

Reviewed-by: Pratyush Yadav <pratyush@kernel.org>

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/20260703112642.65498-1-mdshahid03@gmail.com

[...]

-- 
Regards,
Pratyush Yadav

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

* Re: [PATCH] dm: crash dump: remove redundant NULL check before kvfree()
  2026-07-03 12:03 ` Pratyush Yadav
@ 2026-07-03 13:28   ` Coiby Xu
  2026-07-03 13:44     ` Pratyush Yadav
  0 siblings, 1 reply; 4+ messages in thread
From: Coiby Xu @ 2026-07-03 13:28 UTC (permalink / raw)
  To: Pratyush Yadav
  Cc: mdshahid03, Andrew Morton, Baoquan He, Mike Rapoport,
	Pasha Tatashin, Dave Young, kexec, linux-kernel, Sourabh Jain

On Fri, Jul 03, 2026 at 02:03:32PM +0200, Pratyush Yadav wrote:
>On Fri, Jul 03 2026, mdshahid03@gmail.com wrote:
>
>> 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>
>
>Reviewed-by: Pratyush Yadav <pratyush@kernel.org>

Hi Pratyush,

Thanks for reviewing this patch!

>
>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/20260703112642.65498-1-mdshahid03@gmail.com

I'll send a new version of
https://lore.kernel.org/kexec/20260501234342.2518281-1-coiby.xu@gmail.com/
soon which can address Sashiko's feedback scrutinized by Sourabh.

>
>[...]
>
>-- 
>Regards,
>Pratyush Yadav
>

-- 
Best regards,
Coiby

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

* Re: [PATCH] dm: crash dump: remove redundant NULL check before kvfree()
  2026-07-03 13:28   ` Coiby Xu
@ 2026-07-03 13:44     ` Pratyush Yadav
  0 siblings, 0 replies; 4+ messages in thread
From: Pratyush Yadav @ 2026-07-03 13:44 UTC (permalink / raw)
  To: Coiby Xu
  Cc: Pratyush Yadav, mdshahid03, Andrew Morton, Baoquan He,
	Mike Rapoport, Pasha Tatashin, Dave Young, kexec, linux-kernel,
	Sourabh Jain

On Fri, Jul 03 2026, Coiby Xu wrote:

> On Fri, Jul 03, 2026 at 02:03:32PM +0200, Pratyush Yadav wrote:
>>On Fri, Jul 03 2026, mdshahid03@gmail.com wrote:
>>
>>> 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>
>>
>>Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
>
> Hi Pratyush,
>
> Thanks for reviewing this patch!
>
>>
>>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/20260703112642.65498-1-mdshahid03@gmail.com
>
> I'll send a new version of
> https://lore.kernel.org/kexec/20260501234342.2518281-1-coiby.xu@gmail.com/
> soon which can address Sashiko's feedback scrutinized by Sourabh.

Oh, great. Thanks!

-- 
Regards,
Pratyush Yadav

^ permalink raw reply	[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