Skip to contentSkip to conversation

usb: core: phy: fix return value of usb_phy_roothub_exit()

PATCH New Martin Blumenstingl 2 participants 4 messages Mar 24, 2018 – Mar 27, 2018

Subsystems (2)
lore
Share & tools
lore

Martin Blumenstingl

author reviewer
#0 lore raw

PATCH 1/1 usb: core: phy: fix return value of usb_phy_roothub_exit()

usb_phy_roothub_exit() should return the error code from the phy_exit() call if exiting the PHY failed.
However, since a wrong variable is used usb_phy_roothub_exit() currently always returns 0, even if one of the phy_exit calls returned an error. Fix this by assigning the error code from phy_exit() to the "ret" variable to propagate the error correctly.

Fixes 07dbff0ddbd86c ("usb: core: add a wrapper for the USB PHYs on the HCD")
---
 drivers/usb/core/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/phy.c +1 -1
index 09b7c43c0ea4..f19aaa3c899c 100644
@@ -111,7 +111,7 @@ int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub)
 	list_for_each_entry(roothub_entry, head, list) {
 		err = phy_exit(roothub_entry->phy);
 		if (err)
-			ret = ret;
+			ret = err;
 	}
 
 	return ret;
Signature · 1 line
2.16.2
#1 lore raw

PATCH 1/1 usb: core: phy: fix return value of usb_phy_roothub_exit()

Quoted 18 lines · Martin Blumenstingl

usb_phy_roothub_exit() should return the error code from the phy_exit() call if exiting the PHY failed.
However, since a wrong variable is used usb_phy_roothub_exit() currently always returns 0, even if one of the phy_exit calls returned an error. Fix this by assigning the error code from phy_exit() to the "ret" variable to propagate the error correctly.

Fixes 07dbff0ddbd86c ("usb: core: add a wrapper for the USB PHYs on the HCD")
---
 drivers/usb/core/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/phy.c +0 -0
index 09b7c43c0ea4..f19aaa3c899c 100644

drivers/usb/core/phy.c int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub) · line 114

Quoted 5 lines
drivers/usb/core/phy.c +1 -1
@@ -111,7 +111,7 @@ int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub)
 	list_for_each_entry(roothub_entry, head, list) {
 		err = phy_exit(roothub_entry->phy);
 		if (err)
-			ret = ret;
+			ret = err;

Need break the loop?

Quoted 3 lines
drivers/usb/core/phy.c +0 -0
 	}
 
 	return ret;
author reviewer
#2 lore raw

PATCH 1/1 usb: core: phy: fix return value of usb_phy_roothub_exit()

Hi Chunfeng,

Quoted 14 lines · Chunfeng Yun
Quoted 13 lines · Martin Blumenstingl

usb_phy_roothub_exit() should return the error code from the phy_exit() call if exiting the PHY failed.
However, since a wrong variable is used usb_phy_roothub_exit() currently always returns 0, even if one of the phy_exit calls returned an error. Fix this by assigning the error code from phy_exit() to the "ret" variable to propagate the error correctly.

Fixes 07dbff0ddbd86c ("usb: core: add a wrapper for the USB PHYs on the HCD")
---
 drivers/usb/core/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 11 lines

drivers/usb/core/phy.c int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub) · line 114

Quoted 10 lines
drivers/usb/core/phy.c +1 -1
index 09b7c43c0ea4..f19aaa3c899c 100644
@@ -111,7 +111,7 @@ int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub)
      list_for_each_entry(roothub_entry, head, list) {
              err = phy_exit(roothub_entry->phy);
              if (err)
-                     ret = ret;
+                     ret = err;

Need break the loop?

in the original implementation I decided not to break the loop here so phy_exit is called for all PHYs -> only the problematic ones will remain initialized
(in the _power_on implementation we can try to fix the state by adding a break and then calling _power_off for all PHYs before the "broken" one where _power_on failed)

also if phy_exit fails then something is probably very wrong

do you have any specific use-case in mind where the missing break could be a problem?

Quoted 5 lines

drivers/usb/core/phy.c int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub) · line 117

Quoted 3 lines
drivers/usb/core/phy.c +0 -0
      }
 
      return ret;

Regards
Martin

#3 lore raw

PATCH 1/1 usb: core: phy: fix return value of usb_phy_roothub_exit()

Hi,

Quoted 28 lines · Martin Blumenstingl

Hi Chunfeng,

Quoted 14 lines · Chunfeng Yun
Quoted 13 lines · Martin Blumenstingl

usb_phy_roothub_exit() should return the error code from the phy_exit() call if exiting the PHY failed.
However, since a wrong variable is used usb_phy_roothub_exit() currently always returns 0, even if one of the phy_exit calls returned an error. Fix this by assigning the error code from phy_exit() to the "ret" variable to propagate the error correctly.

Fixes 07dbff0ddbd86c ("usb: core: add a wrapper for the USB PHYs on the HCD")
---
 drivers/usb/core/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 11 lines

drivers/usb/core/phy.c int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub) · line 114

Quoted 10 lines
drivers/usb/core/phy.c +1 -1
index 09b7c43c0ea4..f19aaa3c899c 100644
@@ -111,7 +111,7 @@ int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub)
      list_for_each_entry(roothub_entry, head, list) {
              err = phy_exit(roothub_entry->phy);
              if (err)
-                     ret = ret;
+                     ret = err;

Need break the loop?

Quoted 7 lines

in the original implementation I decided not to break the loop here so phy_exit is called for all PHYs -> only the problematic ones will remain initialized
(in the _power_on implementation we can try to fix the state by adding a break and then calling _power_off for all PHYs before the "broken" one where _power_on failed)

got it

Quoted 4 lines

also if phy_exit fails then something is probably very wrong

do you have any specific use-case in mind where the missing break could be a problem?

No

Quoted 10 lines
Quoted 6 lines

drivers/usb/core/phy.c int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub) · line 117

Quoted 4 lines
drivers/usb/core/phy.c +0 -0
      }
 
      return ret;

Regards
Martin