[PATCH] ata: libata-scsi: set the field pointer when rejecting CDL

From: shao.mingyin

Date: Thu Oct 29 2026 - 07:09:28 EST


From: Shao Mingyin <shao.mingyin@xxxxxxxxxx>

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@xxxxxxxxxx>
---
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");