Skip to content

Commit 9eaa88c

Browse files
committed
Merge tag 'libata-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata
Pull libata fix from Damien Le Moal: "A single fix for this cycle: - Check that ATA16 passthrough commands that do not transfer any data have a DMA direction set to DMA_NONE (From George)" * tag 'libata-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata: libata: if T_LENGTH is zero, dma direction should be DMA_NONE
2 parents 1887bf5 + 5da5231 commit 9eaa88c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/ata/libata-scsi.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,8 +2859,19 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
28592859
goto invalid_fld;
28602860
}
28612861

2862-
if (ata_is_ncq(tf->protocol) && (cdb[2 + cdb_offset] & 0x3) == 0)
2863-
tf->protocol = ATA_PROT_NCQ_NODATA;
2862+
if ((cdb[2 + cdb_offset] & 0x3) == 0) {
2863+
/*
2864+
* When T_LENGTH is zero (No data is transferred), dir should
2865+
* be DMA_NONE.
2866+
*/
2867+
if (scmd->sc_data_direction != DMA_NONE) {
2868+
fp = 2 + cdb_offset;
2869+
goto invalid_fld;
2870+
}
2871+
2872+
if (ata_is_ncq(tf->protocol))
2873+
tf->protocol = ATA_PROT_NCQ_NODATA;
2874+
}
28642875

28652876
/* enable LBA */
28662877
tf->flags |= ATA_TFLAG_LBA;

0 commit comments

Comments
 (0)