mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: Suchit Karunakaran <suchitkarunakaran@gmail.com>, coxu@redhat.com
Cc: akpm@linux-foundation.org, vgoyal@redhat.com, dyoung@redhat.com,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	skhan@linuxfoundation.org
Subject: Re: [PATCH] dm-crypt: remove ineffective comparison
Date: Wed, 1 Oct 2025 20:42:17 +0800	[thread overview]
Message-ID: <aN0hqT/iTAWodgXJ@MiWiFi-R3L-srv> (raw)
In-Reply-To: <20251001120254.24980-1-suchitkarunakaran@gmail.com>

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
> 


      reply	other threads:[~2025-10-01 12:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-01 12:02 Suchit Karunakaran
2025-10-01 12:42 ` Baoquan He [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aN0hqT/iTAWodgXJ@MiWiFi-R3L-srv \
    --to=bhe@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=coxu@redhat.com \
    --cc=dyoung@redhat.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=suchitkarunakaran@gmail.com \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®