usb: typec: tcpm: Fix undefined behavior due to shift overflowing the constant
authorBorislav Petkov <bp@suse.de>
Tue, 5 Apr 2022 15:15:13 +0000 (17:15 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 21 Apr 2022 16:33:56 +0000 (18:33 +0200)
Fix:

  drivers/usb/typec/tcpm/tcpm.c: In function ‘run_state_machine’:
  drivers/usb/typec/tcpm/tcpm.c:4724:3: error: case label does not reduce to an integer constant
     case BDO_MODE_TESTDATA:
     ^~~~

See https://lore.kernel.org/r/YkwQ6%2BtIH8GQpuct@zn.tnic for the gory
details as to why it triggers with older gccs only.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Link: https://lore.kernel.org/r/20220405151517.29753-8-bp@alien8.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/usb/pd_bdo.h

index 033fe3e1714112da0f802fed57bf175ef4558cc1..7c25b88d79f9002353308c296161b62c18309554 100644 (file)
@@ -15,7 +15,7 @@
 #define BDO_MODE_CARRIER2      (5 << 28)
 #define BDO_MODE_CARRIER3      (6 << 28)
 #define BDO_MODE_EYE           (7 << 28)
-#define BDO_MODE_TESTDATA      (8 << 28)
+#define BDO_MODE_TESTDATA      (8U << 28)
 
 #define BDO_MODE_MASK(mode)    ((mode) & 0xf0000000)