lkml.org 
[lkml]   [2019]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] PHY: Variable "val" in function pistachio_usb_phy_power_on() could be uninitialized
Date
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 <yzhai003@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
\
 
 \ /
  Last update: 2019-02-05 23:34    [W:0.057 / U:3.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site