diff mbox series

phy: qcom: m31: Remove unwanted qphy->vreg is NULL check

Message ID 1694069452-3794-1-git-send-email-quic_varada@quicinc.com
State Accepted
Commit ecec1de5c58f8f3ab6959fcf8d68752eeb65311d
Headers show
Series phy: qcom: m31: Remove unwanted qphy->vreg is NULL check | expand

Commit Message

Varadarajan Narayanan Sept. 7, 2023, 6:50 a.m. UTC
Fix the following Smatch complaint:
	drivers/phy/qualcomm/phy-qcom-m31.c:175 m31usb_phy_init()
	warn: variable dereferenced before check 'qphy->vreg' (see line 167)

drivers/phy/qualcomm/phy-qcom-m31.c
   166
   167		ret = regulator_enable(qphy->vreg);
                                       ^^^^^^^^^^
Unchecked dereference

   168		if (ret) {
   169			dev_err(&phy->dev, "failed to enable regulator, %d\n", ret);
   170			return ret;
   171		}
   172
   173		ret = clk_prepare_enable(qphy->clk);
   174		if (ret) {
   175			if (qphy->vreg)
                            ^^^^^^^^^^
Checked too late

   176				regulator_disable(qphy->vreg);
   177			dev_err(&phy->dev, "failed to enable cfg ahb clock, %d\n", ret);

Since the phy will not get registered if qphy->vreg is NULL,
this check is not needed.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-phy/cbd26132-c624-44b7-a073-73222b287338@moroto.mountain/T/#u
Fixes: 08e49af50701 ("phy: qcom: Introduce M31 USB PHY driver")
Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com>
---
 drivers/phy/qualcomm/phy-qcom-m31.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Vinod Koul Sept. 21, 2023, 2:26 p.m. UTC | #1
On Thu, 07 Sep 2023 12:20:52 +0530, Varadarajan Narayanan wrote:
> Fix the following Smatch complaint:
> 	drivers/phy/qualcomm/phy-qcom-m31.c:175 m31usb_phy_init()
> 	warn: variable dereferenced before check 'qphy->vreg' (see line 167)
> 
> drivers/phy/qualcomm/phy-qcom-m31.c
>    166
>    167		ret = regulator_enable(qphy->vreg);
>                                        ^^^^^^^^^^
> Unchecked dereference
> 
> [...]

Applied, thanks!

[1/1] phy: qcom: m31: Remove unwanted qphy->vreg is NULL check
      commit: ecec1de5c58f8f3ab6959fcf8d68752eeb65311d

Best regards,
diff mbox series

Patch

diff --git a/drivers/phy/qualcomm/phy-qcom-m31.c b/drivers/phy/qualcomm/phy-qcom-m31.c
index 1875fe3..5e8f657 100644
--- a/drivers/phy/qualcomm/phy-qcom-m31.c
+++ b/drivers/phy/qualcomm/phy-qcom-m31.c
@@ -172,8 +172,7 @@  static int m31usb_phy_init(struct phy *phy)
 
 	ret = clk_prepare_enable(qphy->clk);
 	if (ret) {
-		if (qphy->vreg)
-			regulator_disable(qphy->vreg);
+		regulator_disable(qphy->vreg);
 		dev_err(&phy->dev, "failed to enable cfg ahb clock, %d\n", ret);
 		return ret;
 	}