From: liujing <liujing@cmss.chinamobile.com>
To: Thomas Renninger <trenn@suse.com>, Shuah Khan <shuah@kernel.org>,
"John B . Wyatt IV" <jwyatt@redhat.com>,
John Kacur <jkacur@redhat.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Liu Jing <liujing@cmss.chinamobile.com>
Subject: [PATCH] tools cpupower: Fix signed shift UB in amd_fam14h_idle
Date: Thu, 3 Sep 2026 16:26:44 +0800 [thread overview]
Message-ID: <20260903082644.5149-1-liujing@cmss.chinamobile.com> (raw)
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.
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)
next reply other threads:[~2026-09-03 8:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 8:26 liujing [this message]
2026-09-04 17:57 ` [PATCH] tools cpupower: Fix signed shift UB in amd_fam14h_idle Shuah Khan
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=20260903082644.5149-1-liujing@cmss.chinamobile.com \
--to=liujing@cmss.chinamobile.com \
--cc=jkacur@redhat.com \
--cc=jwyatt@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox