diff mbox series

[2/3] PCI: qcom: Prevent potential error pointer dereference

Message ID 20240708180539.1447307-3-dan.carpenter@linaro.org
State Accepted
Commit 9553636b5757789536d0d23c83e7fba11812f958
Headers show
Series [1/3] PCI: qcom: Fix missing error code in qcom_pcie_probe() | expand

Commit Message

Dan Carpenter July 8, 2024, 6:05 p.m. UTC
Only call dev_pm_opp_put() if dev_pm_opp_find_freq_exact() succeeds.
Otherwise it leads to an error pointer dereference.

Fixes: 78b5f6f8855e ("PCI: qcom: Add OPP support to scale performance")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/pci/controller/dwc/pcie-qcom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Manivannan Sadhasivam July 9, 2024, 5:14 a.m. UTC | #1
On Mon, Jul 08, 2024 at 01:05:37PM -0500, Dan Carpenter wrote:
> Only call dev_pm_opp_put() if dev_pm_opp_find_freq_exact() succeeds.
> Otherwise it leads to an error pointer dereference.
> 
> Fixes: 78b5f6f8855e ("PCI: qcom: Add OPP support to scale performance")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

- Mani

> ---
>  drivers/pci/controller/dwc/pcie-qcom.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
> index 1d36311f9adb..e06c4ad3a72a 100644
> --- a/drivers/pci/controller/dwc/pcie-qcom.c
> +++ b/drivers/pci/controller/dwc/pcie-qcom.c
> @@ -1443,8 +1443,8 @@ static void qcom_pcie_icc_opp_update(struct qcom_pcie *pcie)
>  			if (ret)
>  				dev_err(pci->dev, "Failed to set OPP for freq (%lu): %d\n",
>  					freq_kbps * width, ret);
> +			dev_pm_opp_put(opp);
>  		}
> -		dev_pm_opp_put(opp);
>  	}
>  }
>  
> -- 
> 2.43.0
>
Krzysztof WilczyƄski July 10, 2024, 5:43 a.m. UTC | #2
Hello,

[...]
> > Only call dev_pm_opp_put() if dev_pm_opp_find_freq_exact() succeeds.
> > Otherwise it leads to an error pointer dereference.
> > 
> > Fixes: 78b5f6f8855e ("PCI: qcom: Add OPP support to scale performance")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> 
> Tested-by: Anders Roxell <anders.roxell@linaro.org>
> 
> Applied this patch ontop of linux-next tag, next-20240709.
> 
> Booted fine on dragonboard-845c HW.

Thank you for testing!

I took the liberty and added your Tested-by: tag to the relevant commits
on our controller/qcom branch.

	Krzysztof
diff mbox series

Patch

diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
index 1d36311f9adb..e06c4ad3a72a 100644
--- a/drivers/pci/controller/dwc/pcie-qcom.c
+++ b/drivers/pci/controller/dwc/pcie-qcom.c
@@ -1443,8 +1443,8 @@  static void qcom_pcie_icc_opp_update(struct qcom_pcie *pcie)
 			if (ret)
 				dev_err(pci->dev, "Failed to set OPP for freq (%lu): %d\n",
 					freq_kbps * width, ret);
+			dev_pm_opp_put(opp);
 		}
-		dev_pm_opp_put(opp);
 	}
 }