* [PATCH] crash_dump: Remove redundant less-than-zero check
@ 2026-02-28 8:51 Thorsten Blum
2026-02-28 19:02 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-02-28 8:51 UTC (permalink / raw)
To: Andrew Morton, Baoquan He, Vivek Goyal, Dave Young
Cc: Thorsten Blum, kexec, linux-kernel
'key_count' is an 'unsigned int' and cannot be less than zero. Remove
the redundant condition.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
kernel/crash_dump_dm_crypt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/crash_dump_dm_crypt.c b/kernel/crash_dump_dm_crypt.c
index 1f4067fbdb94..27a144920562 100644
--- a/kernel/crash_dump_dm_crypt.c
+++ b/kernel/crash_dump_dm_crypt.c
@@ -115,7 +115,7 @@ static int restore_dm_crypt_keys_to_thread_keyring(void)
addr = dm_crypt_keys_addr;
dm_crypt_keys_read((char *)&key_count, sizeof(key_count), &addr);
- if (key_count < 0 || key_count > KEY_NUM_MAX) {
+ if (key_count > KEY_NUM_MAX) {
kexec_dprintk("Failed to read the number of dm-crypt keys\n");
return -1;
}
--
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crash_dump: Remove redundant less-than-zero check
2026-02-28 8:51 [PATCH] crash_dump: Remove redundant less-than-zero check Thorsten Blum
@ 2026-02-28 19:02 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-02-28 19:02 UTC (permalink / raw)
To: Thorsten Blum; +Cc: Baoquan He, Vivek Goyal, Dave Young, kexec, linux-kernel
On Sat, 28 Feb 2026 09:51:36 +0100 Thorsten Blum <thorsten.blum@linux.dev> wrote:
> 'key_count' is an 'unsigned int' and cannot be less than zero. Remove
> the redundant condition.
>
umm. OK.
> --- a/kernel/crash_dump_dm_crypt.c
> +++ b/kernel/crash_dump_dm_crypt.c
> @@ -115,7 +115,7 @@ static int restore_dm_crypt_keys_to_thread_keyring(void)
>
> addr = dm_crypt_keys_addr;
> dm_crypt_keys_read((char *)&key_count, sizeof(key_count), &addr);
> - if (key_count < 0 || key_count > KEY_NUM_MAX) {
> + if (key_count > KEY_NUM_MAX) {
> kexec_dprintk("Failed to read the number of dm-crypt keys\n");
> return -1;
> }
iirc Linus has said "this is OK". The compiler will eliminate it and
the code still works if the type is later changed to signed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-28 19:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-28 8:51 [PATCH] crash_dump: Remove redundant less-than-zero check Thorsten Blum
2026-02-28 19:02 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox