ata: Fix ZBC_OUT all bit handling
authorDamien Le Moal <damien.lemoal@wdc.com>
Tue, 26 Jun 2018 11:56:55 +0000 (20:56 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Jul 2018 09:39:24 +0000 (11:39 +0200)
commit 6edf1d4cb0acde3a0a5dac849f33031bd7abb7b1 upstream.

If the ALL bit is set in the ZBC_OUT command, the command zone ID field
(block) should be ignored.

Reported-by: David Butterfield <david.butterfield@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Cc: stable@vger.kernel.org
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/ata/libata-scsi.c

index 3f8c3613d6dd6c0f6ab5eca816ff364365041f08..bf5777bc04d35bc4686e985d4dc601433492c1c0 100644 (file)
@@ -3801,7 +3801,14 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc)
                 */
                goto invalid_param_len;
        }
-       if (block >= dev->n_sectors) {
+
+       all = cdb[14] & 0x1;
+       if (all) {
+               /*
+                * Ignore the block address (zone ID) as defined by ZBC.
+                */
+               block = 0;
+       } else if (block >= dev->n_sectors) {
                /*
                 * Block must be a valid zone ID (a zone start LBA).
                 */
@@ -3809,8 +3816,6 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc)
                goto invalid_fld;
        }
 
-       all = cdb[14] & 0x1;
-
        if (ata_ncq_enabled(qc->dev) &&
            ata_fpdma_zac_mgmt_out_supported(qc->dev)) {
                tf->protocol = ATA_PROT_NCQ_NODATA;