Skip to content

libata: ata_pio_task() accessing 'ap->pio_task_state' fix

Albert Lee linux-ide 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 4 repliesIn review

Changes from the cover letter

1/2: Modify ata_pio_complete() and ata_pio_block() to return
whether qc has been completed.

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2libata: ata_pio_complete() and ata_pio_block() return valuedrivers/scsi/libata-core.c+16 -70 replies
2/2libata: ata_pio_task() fixdrivers/scsi/libata-core.c+14 -100 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] libata: ata_pio_task() accessing 'ap->pio_task_state' fix

Jeff,

During PIO, after calling ata_poll_qc_complete(), the next command might be running and the value of 'ap->pio_task_state' might have been changed. Accessing 'ap->pio_task_state' is not safe at this point.

Ex.
qc 1 completed. queuing a final task with ap->pio_task_state == PIO_ST_IDLE. qc 2 started, queuing a new task with ap->pio_task_state set to PIO_ST. qc 1 read ap->pio_task_state as PIO_ST; not PIO_ST_IDLE as expected. => 2 qc running in the workqueue with pio_task_state PIO_ST.

Changes:
1/2: Modify ata_pio_complete() and ata_pio_block() to return
whether qc has been completed.

2/2: Modify ata_pio_task() to check the return value. Only queue next
step and

       access 'ap->pio_task_state' if the command is not completed.

Patch for 2.6.13 (80ac2912f846c01d702774bb6aa7100ec71e88b9). Tested on x86 with Promise PDC20275 and LG DVD-Multi drive. For your review and advice, thanks.

Albert