From: Niklas Cassel <cassel@kernel.org>
To: shao.mingyin@zte.com.cn
Cc: dlemoal@kernel.org, linux-ide@vger.kernel.org
Subject: Re: [PATCH] ata: libata-scsi: set the field pointer when rejecting CDL
Date: Tue, 3 Nov 2026 22:18:26 +0100 [thread overview]
Message-ID: <aupPouIrF_SkU0jz@ryzen> (raw)
In-Reply-To: <aupMUrNn7PkrJg6W@ryzen>
On Tue, Nov 03, 2026 at 10:04:18PM +0100, Niklas Cassel wrote:
> Hello Shao,
>
> On Thu, Oct 29, 2026 at 07:03:14PM +0800, shao.mingyin@zte.com.cn wrote:
> > From: Shao Mingyin <shao.mingyin@zte.com.cn>
> >
> > ata_mselect_control_ata_feature() rejects enabling CDL while NCQ
> > priority is enabled, but unlike its other error branches it returns
> > without setting *fp.
> >
> > ata_scsi_mode_select_xlat() initializes fp to 0xffff and, when the
> > handler fails, adds the mode select header and block descriptor lengths
> > to it. The resulting sense data then reports a field pointer far
> > outside of the submitted parameter list instead of the byte that has to
> > be changed.
> >
> > Set *fp to the beginning of the mode page data, as the other branches of
> > this function do.
> >
> > Fixes: df60f9c64576 ("scsi: ata: libata: Add ATA feature control sub-page translation")
> > Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
> > ---
> > diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> > index 5cde90fe594e..c07c1ff09757 100644
> > --- a/drivers/ata/libata-scsi.c
> > +++ b/drivers/ata/libata-scsi.c
> > @@ -4494,6 +4494,7 @@ static int ata_mselect_control_ata_feature(struct ata_queued_cmd *qc,
> > if (dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLED) {
> > ata_dev_err(dev,
> > "NCQ priority must be disabled to enable CDL\n");
> > + *fp = 0;
> > return -EINVAL;
> > }
> > ata_dev_dbg(dev, "Enabling CDL\n");
>
>
> Setting fp to zero looks very wrong to me, even though with the current
> overly complicated code where buf and fp was using completely different
> offsets, it was actually correct.
Sorry, to clarify, 0 would have been wrong anyway, but because of existing
bugs in ata_scsi_mode_select_xlat() related to fp, not because your patch
was wrong:
https://lore.kernel.org/linux-ide/20261103205448.931471-10-cassel@kernel.org
Parameter list Before After Correct
CDL enable while NCQ priority is enabled 7 12 12
Kind regards,
Niklas
next prev parent reply other threads:[~2026-11-03 21:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 11:03 [PATCH] ata: libata-scsi: set the field pointer when rejecting CDL shao.mingyin
2026-11-03 21:04 ` Niklas Cassel
2026-11-03 21:18 ` Niklas Cassel [this message]
2026-11-04 1:55 ` shao.mingyin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aupPouIrF_SkU0jz@ryzen \
--to=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=shao.mingyin@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox