linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ufs: core: Initialize a value of an attribute at ufshcd_dme_get_attr()
       [not found] <CGME20251020061545epcas1p2c494b8e57d424f1b2dfdcc9eef6e669e@epcas1p2.samsung.com>
@ 2025-10-20  6:15 ` Wonkon Kim
  2025-10-20  6:15   ` [PATCH 1/2] ufs: core: Initialize a value of an attribute as returned by uic cmd Wonkon Kim
                     ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Wonkon Kim @ 2025-10-20  6:15 UTC (permalink / raw)
  To: bvanassche, James.Bottomley, martin.petersen, peter.wang,
	linux-scsi, linux-kernel
  Cc: wkon.kim

From: wkon-kim <wkon.kim@samsung.com>

It needs to initialize a value of an attribute at ufshcd_dme_get_attr().

Wonkon Kim(2):
  ufs: core: Initialize a value of an attribute as returned by uic cmd
  ufs: core: Declare tx_lanes witout initialization

 drivers/ufs/core/ufshcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.34.1


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

* [PATCH 1/2] ufs: core: Initialize a value of an attribute as returned by uic cmd
  2025-10-20  6:15 ` [PATCH 0/2] ufs: core: Initialize a value of an attribute at ufshcd_dme_get_attr() Wonkon Kim
@ 2025-10-20  6:15   ` Wonkon Kim
  2025-10-20  6:15   ` [PATCH 2/2] ufs: core: Declare tx_lanes witout initialization Wonkon Kim
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Wonkon Kim @ 2025-10-20  6:15 UTC (permalink / raw)
  To: bvanassche, James.Bottomley, martin.petersen, peter.wang,
	linux-scsi, linux-kernel
  Cc: wkon.kim

From: wkon-kim <wkon.kim@samsung.com>

If ufshcd_send_cmd() fails, *mib_val may have a garbage value.
It can get an unintended value of an attribute.
ufshcd_dme_get_attr() always initializes *mib_val.

Fixes: 12b4fdb4f6bc ("[SCSI] ufs: add dme configuration primitives")
Signed-off-by: Wonkon Kim <wkon.kim@samsung.com>
---
 drivers/ufs/core/ufshcd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 9a43102b2b21..969f3a23bf92 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)
-- 
2.34.1


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

* [PATCH 2/2] ufs: core: Declare tx_lanes witout initialization
  2025-10-20  6:15 ` [PATCH 0/2] ufs: core: Initialize a value of an attribute at ufshcd_dme_get_attr() Wonkon Kim
  2025-10-20  6:15   ` [PATCH 1/2] ufs: core: Initialize a value of an attribute as returned by uic cmd Wonkon Kim
@ 2025-10-20  6:15   ` Wonkon Kim
  2025-10-20 16:01   ` [PATCH 0/2] ufs: core: Initialize a value of an attribute at ufshcd_dme_get_attr() Bart Van Assche
  2025-10-22  2:27   ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Wonkon Kim @ 2025-10-20  6:15 UTC (permalink / raw)
  To: bvanassche, James.Bottomley, martin.petersen, peter.wang,
	linux-scsi, linux-kernel
  Cc: wkon.kim

From: wkon-kim <wkon.kim@samsung.com>

A value of an attribute will be initialized at ufshcd_dme_get_attr().
There is no need to initialize a tx_lanes.

Signed-off-by: Wonkon Kim <wkon.kim@samsung.com>
---
 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 969f3a23bf92..6858f005cc8b 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -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


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

* Re: [PATCH 0/2] ufs: core: Initialize a value of an attribute at ufshcd_dme_get_attr()
  2025-10-20  6:15 ` [PATCH 0/2] ufs: core: Initialize a value of an attribute at ufshcd_dme_get_attr() Wonkon Kim
  2025-10-20  6:15   ` [PATCH 1/2] ufs: core: Initialize a value of an attribute as returned by uic cmd Wonkon Kim
  2025-10-20  6:15   ` [PATCH 2/2] ufs: core: Declare tx_lanes witout initialization Wonkon Kim
@ 2025-10-20 16:01   ` Bart Van Assche
  2025-10-22  2:27   ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2025-10-20 16:01 UTC (permalink / raw)
  To: Wonkon Kim, James.Bottomley, martin.petersen, peter.wang,
	linux-scsi, linux-kernel

On 10/19/25 11:15 PM, Wonkon Kim wrote:
> It needs to initialize a value of an attribute at ufshcd_dme_get_attr().

For both patches:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>


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

* Re: [PATCH 0/2] ufs: core: Initialize a value of an attribute at ufshcd_dme_get_attr()
  2025-10-20  6:15 ` [PATCH 0/2] ufs: core: Initialize a value of an attribute at ufshcd_dme_get_attr() Wonkon Kim
                     ` (2 preceding siblings ...)
  2025-10-20 16:01   ` [PATCH 0/2] ufs: core: Initialize a value of an attribute at ufshcd_dme_get_attr() Bart Van Assche
@ 2025-10-22  2:27   ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2025-10-22  2:27 UTC (permalink / raw)
  To: Wonkon Kim
  Cc: bvanassche, James.Bottomley, martin.petersen, peter.wang,
	linux-scsi, linux-kernel


Wonkon,

> It needs to initialize a value of an attribute at
> ufshcd_dme_get_attr().

Applied to 6.18/scsi-fixes, thanks!

-- 
Martin K. Petersen

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

end of thread, other threads:[~2025-10-22  2:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20251020061545epcas1p2c494b8e57d424f1b2dfdcc9eef6e669e@epcas1p2.samsung.com>
2025-10-20  6:15 ` [PATCH 0/2] ufs: core: Initialize a value of an attribute at ufshcd_dme_get_attr() Wonkon Kim
2025-10-20  6:15   ` [PATCH 1/2] ufs: core: Initialize a value of an attribute as returned by uic cmd Wonkon Kim
2025-10-20  6:15   ` [PATCH 2/2] ufs: core: Declare tx_lanes witout initialization Wonkon Kim
2025-10-20 16:01   ` [PATCH 0/2] ufs: core: Initialize a value of an attribute at ufshcd_dme_get_attr() Bart Van Assche
2025-10-22  2:27   ` Martin K. Petersen

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).