All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: liujing <liujing@cmss.chinamobile.com>,
	Thomas Renninger <trenn@suse.com>, Shuah Khan <shuah@kernel.org>,
	"John B . Wyatt IV" <jwyatt@redhat.com>,
	John Kacur <jkacur@redhat.com>,
	Shuah Khan <skhan@linuxfoundation.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] tools cpupower: Fix signed shift UB in amd_fam14h_idle
Date: Fri, 4 Sep 2026 11:57:43 -0600	[thread overview]
Message-ID: <14f16376-a0fa-4ea4-b14f-65eac5839bc0@linuxfoundation.org> (raw)
In-Reply-To: <20260903082644.5149-1-liujing@cmss.chinamobile.com>

On 9/3/26 02:26, liujing wrote:
> From: Liu Jing <liujing@cmss.chinamobile.com>
> 
> In amd_fam14h_get_nb_power(), the expression `1 << 31` performs a
> signed integer shift, which is undefined behavior in C.
> 
> Fix it by using `1U << 31` to perform an unsigned shift.

How did you find this problem?

> 
> Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com>
> ---
> --- a/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
> +++ b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
> @@ -270,7 +270,7 @@
>   {
>   	uint32_t val;
>   	val = pci_read_long(amd_fam14h_pci_dev, PCI_NBP1_CAP_OFFSET);
> -	return val & (1 << 31);
> +	return val & (1U << 31);
>   }
>   
>   struct cpuidle_monitor *amd_fam14h_register(void)
> 
> 
> 
> 

thanks,
-- Shuah


      reply	other threads:[~2026-09-04 17:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  8:26 [PATCH] tools cpupower: Fix signed shift UB in amd_fam14h_idle liujing
2026-09-04 17:57 ` Shuah Khan [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=14f16376-a0fa-4ea4-b14f-65eac5839bc0@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=jkacur@redhat.com \
    --cc=jwyatt@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=liujing@cmss.chinamobile.com \
    --cc=shuah@kernel.org \
    --cc=trenn@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.