[PATCH] scsi: ufs: uninitialized variable in ufshcd_devfreq_target()

Dan Carpenter posted 1 patch 1 year, 12 months ago
drivers/ufs/core/ufshcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] scsi: ufs: uninitialized variable in ufshcd_devfreq_target()
Posted by Dan Carpenter 1 year, 12 months ago
There is one goto where "sched_clk_scaling_suspend_work" is true but
"scale_up" is uninitialized.  It leads to a Smatch uninitialized variable
warning:

drivers/ufs/core/ufshcd.c:1589 ufshcd_devfreq_target() error: uninitialized symbol 'scale_up'.

Fixes: 1d969731b87f ("scsi: ufs: core: Only suspend clock scaling if scaling down")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/ufs/core/ufshcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index d10a77d05d2f..a8a9edb7ba24 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -1514,7 +1514,7 @@ static int ufshcd_devfreq_target(struct device *dev,
 	int ret = 0;
 	struct ufs_hba *hba = dev_get_drvdata(dev);
 	ktime_t start;
-	bool scale_up, sched_clk_scaling_suspend_work = false;
+	bool scale_up = false, sched_clk_scaling_suspend_work = false;
 	struct list_head *clk_list = &hba->clk_list_head;
 	struct ufs_clk_info *clki;
 	unsigned long irq_flags;
-- 
2.43.0
Re: [PATCH] scsi: ufs: uninitialized variable in ufshcd_devfreq_target()
Posted by Bart Van Assche 1 year, 11 months ago
On 2/13/24 10:08, Dan Carpenter wrote:
> There is one goto where "sched_clk_scaling_suspend_work" is true but
> "scale_up" is uninitialized.  It leads to a Smatch uninitialized variable
> warning:
> 
> drivers/ufs/core/ufshcd.c:1589 ufshcd_devfreq_target() error: uninitialized symbol 'scale_up'.
> 
> Fixes: 1d969731b87f ("scsi: ufs: core: Only suspend clock scaling if scaling down")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>   drivers/ufs/core/ufshcd.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index d10a77d05d2f..a8a9edb7ba24 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -1514,7 +1514,7 @@ static int ufshcd_devfreq_target(struct device *dev,
>   	int ret = 0;
>   	struct ufs_hba *hba = dev_get_drvdata(dev);
>   	ktime_t start;
> -	bool scale_up, sched_clk_scaling_suspend_work = false;
> +	bool scale_up = false, sched_clk_scaling_suspend_work = false;
>   	struct list_head *clk_list = &hba->clk_list_head;
>   	struct ufs_clk_info *clki;
>   	unsigned long irq_flags;

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Re: [PATCH] scsi: ufs: uninitialized variable in ufshcd_devfreq_target()
Posted by Peter Wang (王信友) 1 year, 11 months ago
On Tue, 2024-02-13 at 21:08 +0300, Dan Carpenter wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  There is one goto where "sched_clk_scaling_suspend_work" is true but
> "scale_up" is uninitialized.  It leads to a Smatch uninitialized
> variable
> warning:
> 
> drivers/ufs/core/ufshcd.c:1589 ufshcd_devfreq_target() error:
> uninitialized symbol 'scale_up'.
> 
> Fixes: 1d969731b87f ("scsi: ufs: core: Only suspend clock scaling if
> scaling down")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> 

Reviewed-by: Peter Wang <peter.wang@mediatek.com>