public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs-mediatek: fix uninitialized variable
@ 2019-03-21 13:19 Anders Roxell
  2019-03-21 13:34 ` Stanley Chu
  0 siblings, 1 reply; 2+ messages in thread
From: Anders Roxell @ 2019-03-21 13:19 UTC (permalink / raw)
  To: jejb, martin.petersen, matthias.bgg
  Cc: linux-arm-kernel, Anders Roxell, linux-mediatek, linux-kernel,
	linux-scsi

When building the ufs-mediatek driver variable 'ret' may be used
uninitialized.

../drivers/scsi/ufs/ufs-mediatek.c: In function ‘ufs_mtk_setup_clocks’:
../drivers/scsi/ufs/ufs-mediatek.c:96:6: warning: ‘ret’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int ret;
      ^~~

Rework to return directly instead of using a local variable 'ret'.

Fixes: ddd90623ce26 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 drivers/scsi/ufs/ufs-mediatek.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index ce4767784937..330d68871b06 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -93,7 +93,6 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
 				enum ufs_notify_change_status status)
 {
 	struct ufs_mtk_host *host = ufshcd_get_variant(hba);
-	int ret;
 
 	/*
 	 * In case ufs_mtk_init() is not yet done, simply ignore.
@@ -106,18 +105,18 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
 	switch (status) {
 	case PRE_CHANGE:
 		if (!on)
-			ret = phy_power_off(host->mphy);
+			return phy_power_off(host->mphy);
 		break;
 	case POST_CHANGE:
 		if (on)
-			ret = phy_power_on(host->mphy);
+			return phy_power_on(host->mphy);
 		break;
 	default:
-		ret = -EINVAL;
+		return -EINVAL;
 		break;
 	}
 
-	return ret;
+	return 0;
 }
 
 /**
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] scsi: ufs-mediatek: fix uninitialized variable
  2019-03-21 13:19 [PATCH] scsi: ufs-mediatek: fix uninitialized variable Anders Roxell
@ 2019-03-21 13:34 ` Stanley Chu
  0 siblings, 0 replies; 2+ messages in thread
From: Stanley Chu @ 2019-03-21 13:34 UTC (permalink / raw)
  To: Anders Roxell
  Cc: martin.petersen, linux-scsi, jejb, linux-kernel, linux-mediatek,
	matthias.bgg, linux-arm-kernel

Hi Anders,

On Thu, 2019-03-21 at 14:19 +0100, Anders Roxell wrote:
> When building the ufs-mediatek driver variable 'ret' may be used
> uninitialized.
> 
> ../drivers/scsi/ufs/ufs-mediatek.c: In function ‘ufs_mtk_setup_clocks’:
> ../drivers/scsi/ufs/ufs-mediatek.c:96:6: warning: ‘ret’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>   int ret;
>       ^~~
> 
> Rework to return directly instead of using a local variable 'ret'.
> 
> Fixes: ddd90623ce26 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
> ---
>  drivers/scsi/ufs/ufs-mediatek.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
> index ce4767784937..330d68871b06 100644
> --- a/drivers/scsi/ufs/ufs-mediatek.c
> +++ b/drivers/scsi/ufs/ufs-mediatek.c
> @@ -93,7 +93,6 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
>  				enum ufs_notify_change_status status)
>  {
>  	struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> -	int ret;
>  
>  	/*
>  	 * In case ufs_mtk_init() is not yet done, simply ignore.
> @@ -106,18 +105,18 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
>  	switch (status) {
>  	case PRE_CHANGE:
>  		if (!on)
> -			ret = phy_power_off(host->mphy);
> +			return phy_power_off(host->mphy);
>  		break;
>  	case POST_CHANGE:
>  		if (on)
> -			ret = phy_power_on(host->mphy);
> +			return phy_power_on(host->mphy);
>  		break;
>  	default:
> -		ret = -EINVAL;
> +		return -EINVAL;
>  		break;
>  	}
>  
> -	return ret;
> +	return 0;
>  }
>  
>  /**

This was already fixed by Nathan Chancellor in below patch,
https://lkml.org/lkml/2019/3/20/784

Anyway thanks for sending this fix.

Stanley.



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-03-21 13:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-21 13:19 [PATCH] scsi: ufs-mediatek: fix uninitialized variable Anders Roxell
2019-03-21 13:34 ` Stanley Chu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox