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:04:18 +0100 [thread overview]
Message-ID: <aupMUrNn7PkrJg6W@ryzen> (raw)
In-Reply-To: <202610291903148135Df-fh-xl3zWuRJkq8AXn@zte.com.cn>
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.
I reworked and included your patch in my series:
https://lore.kernel.org/linux-ide/20261103205448.931471-17-cassel@kernel.org/
This way we can set the fp to the logical value for anyone actually
looking at the definition of this mode page in the SAT spec.
(Where the CDL_CTRL field is at offset 4 in the ATA Feature Control mode page)
Kind regards,
Niklas
next prev parent reply other threads:[~2026-11-03 21:04 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 [this message]
2026-11-03 21:18 ` Niklas Cassel
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=aupMUrNn7PkrJg6W@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