Skip to contentSkip to conversation

scsi: ufs-mediatek: fix uninitialized variable

PATCH In review Anders Roxell 2 participants 2 messages Mar 21, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: ufs-mediatek: fix uninitialized variable

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")
---
 drivers/scsi/ufs/ufs-mediatek.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/scsi/ufs/ufs-mediatek.c +4 -5
index ce4767784937..330d68871b06 100644
@@ -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;
 }
 
 /**
Signature · 1 line
2.20.1
#1 lore raw

Hi Anders,

Quoted 41 lines · Anders Roxell

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")
---
 drivers/scsi/ufs/ufs-mediatek.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/scsi/ufs/ufs-mediatek.c +2 -3
index ce4767784937..330d68871b06 100644
@@ -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:

drivers/scsi/ufs/ufs-mediatek.c static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on, · line 122

Quoted 10 lines
drivers/scsi/ufs/ufs-mediatek.c +2 -2
-		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.