* [PATCH] dm-crypt: remove ineffective comparison
@ 2025-10-01 12:02 Suchit Karunakaran
2025-10-01 12:42 ` Baoquan He
0 siblings, 1 reply; 2+ messages in thread
From: Suchit Karunakaran @ 2025-10-01 12:02 UTC (permalink / raw)
To: akpm, bhe, vgoyal, dyoung, kexec; +Cc: linux-kernel, skhan, Suchit Karunakaran
In restore_dm_crypt_keys_to_thread_keyring(), key_count is a global
variable declared as unsigned int. The comparison key_count < 0
is therefore always false and has no effect.
Remove the dead comparison to make the code clearer and
silence static analysis warnings.
Found by Coverity: CID#1649028
Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
---
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 401423ba477d..39cfc13ff350 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;
}
--
2.51.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] dm-crypt: remove ineffective comparison
2025-10-01 12:02 [PATCH] dm-crypt: remove ineffective comparison Suchit Karunakaran
@ 2025-10-01 12:42 ` Baoquan He
0 siblings, 0 replies; 2+ messages in thread
From: Baoquan He @ 2025-10-01 12:42 UTC (permalink / raw)
To: Suchit Karunakaran, coxu; +Cc: akpm, vgoyal, dyoung, kexec, linux-kernel, skhan
CC Coiby,
On 10/01/25 at 05:32pm, Suchit Karunakaran wrote:
> In restore_dm_crypt_keys_to_thread_keyring(), key_count is a global
> variable declared as unsigned int. The comparison key_count < 0
> is therefore always false and has no effect.
> Remove the dead comparison to make the code clearer and
> silence static analysis warnings.
>
> Found by Coverity: CID#1649028
>
> Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
> ---
> 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 401423ba477d..39cfc13ff350 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) {
Sounds reasonable to me,
Acked-by: Baoquan He <bhe@redhat.com>
> kexec_dprintk("Failed to read the number of dm-crypt keys\n");
> return -1;
> }
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-01 12:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-01 12:02 [PATCH] dm-crypt: remove ineffective comparison Suchit Karunakaran
2025-10-01 12:42 ` Baoquan He
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®