[PATCH] crash_dump: Remove redundant less-than-zero check

Andrew Morton akpm at linux-foundation.org
Sat Feb 28 11:02:49 PST 2026


On Sat, 28 Feb 2026 09:51:36 +0100 Thorsten Blum <thorsten.blum at 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.




More information about the kexec mailing list