Re: [PATCH v4 04/12] scsi: ufs: core: Add support for TX Equalization
From: Can Guo
Date: Tue Mar 24 2026 - 08:44:51 EST
On 3/24/2026 7:54 PM, Peter Wang (王信友) wrote:
You are right...
On Tue, 2026-03-24 at 18:09 +0800, Can Guo wrote:
> > > + params = &hba->tx_eq_params[gear - 1];
> > > +
> > > + if (gear < UFS_HS_G1 || gear > UFS_HS_GEAR_MAX) {
> > > + dev_err(hba->dev, "Invalid HS-Gear (%u) for TX
> > > Equalization\n",
> > > + gear);
> > > + return -EINVAL;
> > > + } else if (gear < adaptive_txeq_gear) {
> > > + return 0;
> > > + }
> > > > > > > "gear" should be checked before use?
> I don't understand this comment.
>
Hi Can,
I mean that gear is used here:
params = &hba->tx_eq_params[gear - 1];
If gear is 0, it could be dangerous if params is used.
Therefore, we should move this line after the following check:
if (gear < UFS_HS_G1 || gear > UFS_HS_GEAR_MAX) {
...
}
Let me address it in next version.
Thanks,
Can Guo.
Thanks.
Peter
************* MEDIATEK Confidentiality Notice ********************
The information contained in this e-mail message (including any
attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be
conveyed only to the designated recipient(s). Any use, dissemination,
distribution, printing, retaining or copying of this e-mail (including its
attachments) by unintended recipient(s) is strictly prohibited and may
be unlawful. If you are not an intended recipient of this e-mail, or believe
that you have received this e-mail in error, please notify the sender
immediately (by replying to this e-mail), delete any and all copies of
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!