PHY: Variable "val" in function pistachio_usb_phy_power_on() could be uninitialized
PATCH 1/1 PHY: Variable "val" in function pistachio_usb_phy_power_on() could be uninitialized
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 <[email protected]>
--- drivers/phy/phy-pistachio-usb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/phy/phy-pistachio-usb.c +6 -2
@@ -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 ;
Signature · 1 line
2.17.1