* [PATCH v2] ufs: core: Initialize a value of an attribute as returned by uic cmd
[not found] <CGME20251014044050epcas1p3589b404dec77da9fb9f0f79035c149ca@epcas1p3.samsung.com>
@ 2025-10-14 4:40 ` Wonkon Kim
2025-10-17 9:12 ` Peter Wang (王信友)
2025-10-17 15:54 ` Bart Van Assche
0 siblings, 2 replies; 4+ messages in thread
From: Wonkon Kim @ 2025-10-14 4:40 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 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@samsung.com>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] ufs: core: Initialize a value of an attribute as returned by uic cmd
2025-10-14 4:40 ` [PATCH v2] ufs: core: Initialize a value of an attribute as returned by uic cmd Wonkon Kim
@ 2025-10-17 9:12 ` Peter Wang (王信友)
2025-10-17 15:54 ` Bart Van Assche
1 sibling, 0 replies; 4+ messages in thread
From: Peter Wang (王信友) @ 2025-10-17 9:12 UTC (permalink / raw)
To: linux-scsi@vger.kernel.org, wkon.kim@samsung.com,
bvanassche@acm.org, James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com, linux-kernel@vger.kernel.org
On Tue, 2025-10-14 at 13:40 +0900, Wonkon Kim wrote:
>
> From: wkon-kim <wkon.kim@samsung.com>
>
> 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@samsung.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] ufs: core: Initialize a value of an attribute as returned by uic cmd
2025-10-14 4:40 ` [PATCH v2] ufs: core: Initialize a value of an attribute as returned by uic cmd Wonkon Kim
2025-10-17 9:12 ` Peter Wang (王信友)
@ 2025-10-17 15:54 ` Bart Van Assche
2025-10-20 6:19 ` Wonkon Kim
1 sibling, 1 reply; 4+ messages in thread
From: Bart Van Assche @ 2025-10-17 15:54 UTC (permalink / raw)
To: Wonkon Kim, James.Bottomley, martin.petersen, peter.wang,
linux-scsi, linux-kernel
On 10/13/25 9:40 PM, Wonkon Kim wrote:
> 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),
Please split this patch into two patches: a first patch with the
ufshcd_dme_get_attr() change and a second patch with the
ufshcd_disable_tx_lcc() change. Please also add a Fixes: tag to the
first patch. That will cause the first patch to be included
automatically in stable kernels and also in Android kernels.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2] ufs: core: Initialize a value of an attribute as returned by uic cmd
2025-10-17 15:54 ` Bart Van Assche
@ 2025-10-20 6:19 ` Wonkon Kim
0 siblings, 0 replies; 4+ messages in thread
From: Wonkon Kim @ 2025-10-20 6:19 UTC (permalink / raw)
To: 'Bart Van Assche', James.Bottomley, martin.petersen,
peter.wang, linux-scsi, linux-kernel
> On 10/13/25 9:40 PM, Wonkon Kim wrote:
> > 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),
>
> Please split this patch into two patches: a first patch with the
> ufshcd_dme_get_attr() change and a second patch with the
> ufshcd_disable_tx_lcc() change. Please also add a Fixes: tag to the first
> patch. That will cause the first patch to be included automatically in
> stable kernels and also in Android kernels.
>
> Thanks,
>
> Bart.
Sure. I'll split and update it.
Thanks,
Wonkon Kim.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-20 6:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20251014044050epcas1p3589b404dec77da9fb9f0f79035c149ca@epcas1p3.samsung.com>
2025-10-14 4:40 ` [PATCH v2] ufs: core: Initialize a value of an attribute as returned by uic cmd Wonkon Kim
2025-10-17 9:12 ` Peter Wang (王信友)
2025-10-17 15:54 ` Bart Van Assche
2025-10-20 6:19 ` Wonkon Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox