From: Igor Cudnik <igor@its.rel.pl>
To: gregkh@linuxfoundation.org
Cc: heikki.krogerus@linux.intel.com, mika.westerberg@linux.intel.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Igor Cudnik <igor@its.rel.pl>
Subject: [PATCH 1/1] usb: acpi: fix undefined behavior in USB_ACPI_LOCATION_VALID
Date: Tue, 26 May 2026 19:43:37 +0200 [thread overview]
Message-ID: <20260526174513.15692-1-igor@its.rel.pl> (raw)
USB_ACPI_LOCATION_VALID uses a signed left shift into the sign
bit. Shifting a signed value into the sign bit is undefined behavior.
Use BIT(31) instead.
Found by cppcheck:
drivers/usb/core/usb-acpi.c:221:24: error:
Shifting signed 32-bit value by 31 bits is undefined behaviour
[shiftTooManyBitsSigned]
Fixes: f3ac348e6e045 ("usb: usb-acpi: Set port connect type of not connectable ports correctly")
Signed-off-by: Igor Cudnik <igor@its.rel.pl>
---
drivers/usb/core/usb-acpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index 489dbdc96f94..583aca6d7669 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -197,7 +197,7 @@ static int usb_acpi_add_usb4_devlink(struct usb_device *udev)
* Private to usb-acpi, all the core needs to know is that
* port_dev->location is non-zero when it has been set by the firmware.
*/
-#define USB_ACPI_LOCATION_VALID (1 << 31)
+#define USB_ACPI_LOCATION_VALID BIT(31)
static void
usb_acpi_get_connect_type(struct usb_port *port_dev, acpi_handle *handle)
--
2.53.0
next reply other threads:[~2026-05-26 18:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 17:43 Igor Cudnik [this message]
2026-05-27 8:01 ` [PATCH 1/1] usb: acpi: fix undefined behavior in USB_ACPI_LOCATION_VALID Greg KH
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=20260526174513.15692-1-igor@its.rel.pl \
--to=igor@its.rel.pl \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mika.westerberg@linux.intel.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