ata: Fix racy link clearance
PATCH 1/1 ata: Fix racy link clearance
The ap->sff_pio_task_link gets cleared in a racy way in ata_sff_flush_pio_task(). This may lead to BUG_ON() check in the work, and screw up the whole system.
Along with it, replace BUG_ON() with WARN_ON() and let the work quit gracefully. It's no end of the world, after all.
Signed-off-by Takashi Iwai <[email protected]>
--- drivers/ata/libata-sff.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/ata/libata-sff.c +6 -4
@@ -1271,9 +1271,8 @@ void ata_sff_flush_pio_task(struct ata_port *ap)*/ spin_lock_irq (ap->lock); ap->hsm_task_state =HSM_ST_IDLE ; -spin_unlock_irq (ap->lock); - ap->sff_pio_task_link =NULL ; +spin_unlock_irq (ap->lock);if (ata_msg_ctl (ap))ata_port_dbg (ap,"%s: EXIT\n" , __func__);
@@ -1283,14 +1282,17 @@ static void ata_sff_pio_task(struct work_struct *work) {struct ata_port *ap = container_of(work, struct ata_port, sff_pio_task.work); -struct ata_link *link = ap->sff_pio_task_link; +struct ata_link *link;struct ata_queued_cmd *qc;u8 status;int poll_next;spin_lock_irq (ap->lock); -BUG_ON (ap->sff_pio_task_link ==NULL ); + link = ap->sff_pio_task_link; +if (WARN_ON (!link)) + goto out_unlock; +/* qc can be NULL if timeout occurred */ qc =ata_qc_from_tag (ap, link->active_tag);if (!qc) {
Signature · 1 line
2.19.1