[PATCH v2] ufs: core: Initialize a value of an attribute as returned by uic cmd
From: Wonkon Kim
Date: Tue Oct 14 2025 - 00:40:54 EST
From: wkon-kim <wkon.kim@xxxxxxxxxxx>
If ufshcd_send_cmd() fails, *mib_val has a garbage value.
A value of an attribute can have an unintended result.
ufshcd_dme_get_attr() always initializes *mib_val.
Signed-off-by: Wonkon Kim <wkon.kim@xxxxxxxxxxx>
---
v2:
It is better to check ufshcd_dme_get() return rather than
to initialize argument.
And ufshcd_dme_get_attr() always initializes *mib_val.
drivers/ufs/core/ufshcd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 9a43102b2b21..6858f005cc8b 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -4273,8 +4273,8 @@ int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
get, UIC_GET_ATTR_ID(attr_sel),
UFS_UIC_COMMAND_RETRIES - retries);
- if (mib_val && !ret)
- *mib_val = uic_cmd.argument3;
+ if (mib_val)
+ *mib_val = ret == 0 ? uic_cmd.argument3 : 0;
if (peer && (hba->quirks & UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE)
&& pwr_mode_change)
@@ -4990,7 +4990,7 @@ EXPORT_SYMBOL_GPL(ufshcd_hba_enable);
static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer)
{
- int tx_lanes = 0, i, err = 0;
+ int tx_lanes, i, err = 0;
if (!peer)
ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDTXDATALANES),
--
2.34.1