From 73be16aee500efe04f5d3f45d6164800e2d12d0f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 6 Dec 2018 13:48:32 +0100 Subject: [PATCH] 3.18-stable patches added patches: usb-gadget-dummy-fix-nonsensical-comparisons.patch --- queue-3.18/series | 1 + ...et-dummy-fix-nonsensical-comparisons.patch | 59 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 queue-3.18/usb-gadget-dummy-fix-nonsensical-comparisons.patch diff --git a/queue-3.18/series b/queue-3.18/series index 3a4fb3230d3..814c542f8cc 100644 --- a/queue-3.18/series +++ b/queue-3.18/series @@ -30,3 +30,4 @@ kgdboc-fix-restrict-error.patch kgdboc-fix-warning-with-module-build.patch input-xpad-quirk-all-pdp-xbox-one-gamepads.patch mm-cleancache-fix-corruption-on-missed-inode-invalidation.patch +usb-gadget-dummy-fix-nonsensical-comparisons.patch diff --git a/queue-3.18/usb-gadget-dummy-fix-nonsensical-comparisons.patch b/queue-3.18/usb-gadget-dummy-fix-nonsensical-comparisons.patch new file mode 100644 index 00000000000..594b9a6f8d0 --- /dev/null +++ b/queue-3.18/usb-gadget-dummy-fix-nonsensical-comparisons.patch @@ -0,0 +1,59 @@ +From 7661ca09b2ff98f48693f431bb01fed62830e433 Mon Sep 17 00:00:00 2001 +From: Arnd Bergmann +Date: Thu, 7 Sep 2017 16:14:31 +0200 +Subject: usb: gadget: dummy: fix nonsensical comparisons + +From: Arnd Bergmann + +commit 7661ca09b2ff98f48693f431bb01fed62830e433 upstream. + +gcc-8 points out two comparisons that are clearly bogus +and almost certainly not what the author intended to write: + +drivers/usb/gadget/udc/dummy_hcd.c: In function 'set_link_state_by_speed': +drivers/usb/gadget/udc/dummy_hcd.c:379:31: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] + USB_PORT_STAT_ENABLE) == 1 && + ^~ +drivers/usb/gadget/udc/dummy_hcd.c:381:25: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] + USB_SS_PORT_LS_U0) == 1 && + ^~ + +I looked at the code for a bit and came up with a change that makes +it look like what the author probably meant here. This makes it +look reasonable to me and to gcc, shutting up the warning. + +It does of course change behavior as the two conditions are actually +evaluated rather than being hardcoded to false, and I have made no +attempt at verifying that the changed logic makes sense in the context +of a USB HCD, so that part needs to be reviewed carefully. + +Fixes: 1cd8fd2887e1 ("usb: gadget: dummy_hcd: add SuperSpeed support") +Cc: Tatyana Brokhman +Cc: Felipe Balbi +Acked-by: Alan Stern +Signed-off-by: Arnd Bergmann +Signed-off-by: Felipe Balbi +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/gadget/udc/dummy_hcd.c | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +--- a/drivers/usb/gadget/udc/dummy_hcd.c ++++ b/drivers/usb/gadget/udc/dummy_hcd.c +@@ -313,11 +313,10 @@ static void set_link_state_by_speed(stru + USB_PORT_STAT_CONNECTION) == 0) + dum_hcd->port_status |= + (USB_PORT_STAT_C_CONNECTION << 16); +- if ((dum_hcd->port_status & +- USB_PORT_STAT_ENABLE) == 1 && +- (dum_hcd->port_status & +- USB_SS_PORT_LS_U0) == 1 && +- dum_hcd->rh_state != DUMMY_RH_SUSPENDED) ++ if ((dum_hcd->port_status & USB_PORT_STAT_ENABLE) && ++ (dum_hcd->port_status & ++ USB_PORT_STAT_LINK_STATE) == USB_SS_PORT_LS_U0 && ++ dum_hcd->rh_state != DUMMY_RH_SUSPENDED) + dum_hcd->active = 1; + } + } else { -- 2.47.3