[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20190205223401.18086-1-yzhai003@ucr.edu>
Date: Tue, 5 Feb 2019 14:34:01 -0800
From: Yizhuo <yzhai003@....edu>
To: unlisted-recipients:; (no To-header on input)
Cc: csong@...ucr.edu, zhiyunq@...ucr.edu, Yizhuo <yzhai003@....edu>,
Kishon Vijay Abraham I <kishon@...com>,
linux-kernel@...r.kernel.org
Subject: [PATCH] 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 <yzhai003@....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
Powered by blists - more mailing lists