kernel/crash_dump_dm_crypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
'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
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.
© 2016 - 2026 Red Hat, Inc.