In function pistachio_usb_phy_power_on(), local variable "val"
could be uninitialized if function regmap_read() returns -EINVAL.
However, it will be used directly in the if statement, which
is potentially unsafe.

Signed-off-by: Yizhuo <yzhai...@ucr.edu>
---
 drivers/phy/phy-pistachio-usb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/phy-pistachio-usb.c b/drivers/phy/phy-pistachio-usb.c
index c6db35e6bb63..ae9b6df1667d 100644
--- a/drivers/phy/phy-pistachio-usb.c
+++ b/drivers/phy/phy-pistachio-usb.c
@@ -95,9 +95,13 @@ static int pistachio_usb_phy_power_on(struct phy *phy)
 
        timeout = jiffies + msecs_to_jiffies(200);
        while (time_before(jiffies, timeout)) {
-               unsigned int val;
+               unsigned int val = 0;
 
-               regmap_read(p_phy->cr_top, USB_PHY_STATUS, &val);
+               ret = regmap_read(p_phy->cr_top, USB_PHY_STATUS, &val);
+               if (ret) {
+                       dev_err(p_phy->dev, "Failed to read USB_PHY_STATUS.\n");
+                       goto disable_clk;
+               }
                if (val & USB_PHY_STATUS_VBUS_FAULT) {
                        dev_err(p_phy->dev, "VBUS fault detected\n");
                        ret = -EIO;
-- 
2.17.1

Reply via email to