| From d5fa0b711da74dd01df1c0a527e154621c97d8d6 Mon Sep 17 00:00:00 2001 | |
| From: Sasha Levin <sashal@kernel.org> | |
| Date: Tue, 3 Nov 2026 21:54:56 +0100 | |
| Subject: ata: libata-scsi: set the field pointer when rejecting CDL | |
| From: Shao Mingyin <shao.mingyin@zte.com.cn> | |
| [ Upstream commit 7c972e73641cbe5f77f63c336de15c7a30268d49 ] | |
| 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 offset of the mode page in the parameter list | |
| to it, i.e. the length of the mode parameter header and of the block | |
| descriptors. As fp is a u16, this wraps around, so the resulting sense | |
| data reports the byte before the mode page, i.e. the last byte of the | |
| mode parameter header or of the block descriptors, as the FIELD | |
| POINTER, instead of the byte containing the CDL_CTRL field that | |
| requests enabling CDL. | |
| Set *fp to 4, i.e. to the byte containing the CDL_CTRL field, like the | |
| branch rejecting an invalid CDL_CTRL value does. | |
| Fixes: df60f9c64576 ("scsi: ata: libata: Add ATA feature control sub-page translation") | |
| Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn> | |
| [cassel: set *fp to 4, the offset of CDL_CTRL in the mode page] | |
| Reviewed-by: Damien Le Moal <dlemoal@kernel.org> | |
| Link: https://lore.kernel.org/r/20261103205448.931471-17-cassel@kernel.org | |
| Signed-off-by: Niklas Cassel <cassel@kernel.org> | |
| Signed-off-by: Sasha Levin <sashal@kernel.org> | |
| --- | |
| drivers/ata/libata-scsi.c | 1 + | |
| 1 file changed, 1 insertion(+) | |
| diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c | |
| index 74273bd7d1add..c423a91535563 100644 | |
| --- a/drivers/ata/libata-scsi.c | |
| +++ b/drivers/ata/libata-scsi.c | |
| @@ -4480,6 +4480,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 = 4; | |
| return -EINVAL; | |
| } | |
| ata_dev_dbg(dev, "Enabling CDL\n"); | |
| -- | |
| 2.53.0 | |