[PATCH 1/1] usb: acpi: fix undefined behavior in USB_ACPI_LOCATION_VALID

From: Igor Cudnik

Date: Tue May 26 2026 - 14:32:47 EST


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@xxxxxxxxxx>
---
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