Re: [PATCH v4 04/12] scsi: ufs: core: Add support for TX Equalization
From: Peter Wang (王信友)
Date: Tue Mar 24 2026 - 08:00:08 EST
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) {
...
}
Thanks.
Peter