Make sure to check that the tag of a queued command is valid when
ata_qc_issue() is called, and fail the QC if the tag is not valid, or if
there is an on-going non-NCQ command already on the link.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
struct ata_link *link = qc->dev->link;
u8 prot = qc->tf.protocol;
- /* Make sure only one non-NCQ command is outstanding. */
- WARN_ON_ONCE(ata_tag_valid(link->active_tag));
+ /*
+ * Make sure we have a valid tag and that only one non-NCQ command is
+ * outstanding.
+ */
+ if (WARN_ON_ONCE(!ata_tag_valid(qc->tag)) ||
+ WARN_ON_ONCE(ata_tag_valid(link->active_tag)))
+ goto sys_err;
if (ata_is_ncq(prot)) {
WARN_ON_ONCE(link->sactive & (1 << qc->hw_tag));