linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH5b51a54ae2fa1cc8459b68a28b3c8ca7b7203994] PM / devfreq: mtk-cci: Fix variable deferencing before NULL check
@ 2023-05-18  8:40 Sukrut Bellary
  2023-05-29 14:27 ` Chanwoo Choi
  0 siblings, 1 reply; 2+ messages in thread
From: Sukrut Bellary @ 2023-05-18  8:40 UTC (permalink / raw)
  To: MyungJoo Ham, Kyungmin Park, Chanwoo Choi, Matthias Brugger,
	AngeloGioacchino Del Regno, Liam Girdwood, Mark Brown
  Cc: Sukrut Bellary, linux-pm, linux-arm-kernel, linux-mediatek,
	linux-kernel, kernel-janitors

smatch warning:
drivers/devfreq/mtk-cci-devfreq.c:135 mtk_ccifreq_target()
warn: variable dereferenced before check 'drv' (see line 130)

This is based on static analysis only. Compilation tested.

Signed-off-by: Sukrut Bellary <sukrut.bellary@linux.com>
---
 drivers/devfreq/mtk-cci-devfreq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/devfreq/mtk-cci-devfreq.c b/drivers/devfreq/mtk-cci-devfreq.c
index e5458ada5197..6354622eda65 100644
--- a/drivers/devfreq/mtk-cci-devfreq.c
+++ b/drivers/devfreq/mtk-cci-devfreq.c
@@ -127,7 +127,7 @@ static int mtk_ccifreq_target(struct device *dev, unsigned long *freq,
 			      u32 flags)
 {
 	struct mtk_ccifreq_drv *drv = dev_get_drvdata(dev);
-	struct clk *cci_pll = clk_get_parent(drv->cci_clk);
+	struct clk *cci_pll;
 	struct dev_pm_opp *opp;
 	unsigned long opp_rate;
 	int voltage, pre_voltage, inter_voltage, target_voltage, ret;
@@ -139,6 +139,7 @@ static int mtk_ccifreq_target(struct device *dev, unsigned long *freq,
 		return 0;
 
 	inter_voltage = drv->inter_voltage;
+	cci_pll = clk_get_parent(drv->cci_clk);
 
 	opp_rate = *freq;
 	opp = devfreq_recommended_opp(dev, &opp_rate, 1);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH5b51a54ae2fa1cc8459b68a28b3c8ca7b7203994] PM / devfreq: mtk-cci: Fix variable deferencing before NULL check
  2023-05-18  8:40 [PATCH5b51a54ae2fa1cc8459b68a28b3c8ca7b7203994] PM / devfreq: mtk-cci: Fix variable deferencing before NULL check Sukrut Bellary
@ 2023-05-29 14:27 ` Chanwoo Choi
  0 siblings, 0 replies; 2+ messages in thread
From: Chanwoo Choi @ 2023-05-29 14:27 UTC (permalink / raw)
  To: Sukrut Bellary, MyungJoo Ham, Kyungmin Park, Chanwoo Choi,
	Matthias Brugger, AngeloGioacchino Del Regno, Liam Girdwood,
	Mark Brown
  Cc: linux-pm, linux-arm-kernel, linux-mediatek, linux-kernel,
	kernel-janitors

On 23. 5. 18. 17:40, Sukrut Bellary wrote:
> smatch warning:
> drivers/devfreq/mtk-cci-devfreq.c:135 mtk_ccifreq_target()
> warn: variable dereferenced before check 'drv' (see line 130)
> 
> This is based on static analysis only. Compilation tested.
> 
> Signed-off-by: Sukrut Bellary <sukrut.bellary@linux.com>
> ---
>  drivers/devfreq/mtk-cci-devfreq.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/devfreq/mtk-cci-devfreq.c b/drivers/devfreq/mtk-cci-devfreq.c
> index e5458ada5197..6354622eda65 100644
> --- a/drivers/devfreq/mtk-cci-devfreq.c
> +++ b/drivers/devfreq/mtk-cci-devfreq.c
> @@ -127,7 +127,7 @@ static int mtk_ccifreq_target(struct device *dev, unsigned long *freq,
>  			      u32 flags)
>  {
>  	struct mtk_ccifreq_drv *drv = dev_get_drvdata(dev);
> -	struct clk *cci_pll = clk_get_parent(drv->cci_clk);
> +	struct clk *cci_pll;
>  	struct dev_pm_opp *opp;
>  	unsigned long opp_rate;
>  	int voltage, pre_voltage, inter_voltage, target_voltage, ret;
> @@ -139,6 +139,7 @@ static int mtk_ccifreq_target(struct device *dev, unsigned long *freq,
>  		return 0;
>  
>  	inter_voltage = drv->inter_voltage;
> +	cci_pll = clk_get_parent(drv->cci_clk);
>  
>  	opp_rate = *freq;
>  	opp = devfreq_recommended_opp(dev, &opp_rate, 1);

Applied it. Thanks.

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-29 14:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-18  8:40 [PATCH5b51a54ae2fa1cc8459b68a28b3c8ca7b7203994] PM / devfreq: mtk-cci: Fix variable deferencing before NULL check Sukrut Bellary
2023-05-29 14:27 ` Chanwoo Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).