Since USB_SS_PORT_LS_U0 is 0x0000 the & operation with the port state would
always be 0. Thus the if would never be true. Moreover USB_PORT_STAT_ENABLE
is 0x0002 and as such would never equal to 1. What we actually look for is a
port that is enabled and in U0/link active state.

Thanks to Alan Stern for suggesting the correct test in this case.

Found with coverity: CID 744367, CID 145679

Signed-off-by: Philippe De Swert <[email protected]>
---
 drivers/usb/gadget/dummy_hcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 03a2300..ea191d4 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -312,9 +312,9 @@ static void set_link_state_by_speed(struct dummy_hcd 
*dum_hcd)
                                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 &&
+                            USB_PORT_STAT_ENABLE) != 0 &&
+                           (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;
                }
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to