Skip to content

Commit

Permalink
libata: zero xfer length on ATAPI data xfer IRQ is HSM violation
Browse files Browse the repository at this point in the history
Treat zero xfer length as HSM violation.  While at it, add
unlikely()'s to ATAPI ireason and transfer length checks.

tj: Formatted patch and added unlikely()'s.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
  • Loading branch information
Albert Lee authored and Jeff Garzik committed Jan 23, 2008
1 parent 93f8fec commit 0106372
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5309,12 +5309,15 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc)
bytes = (bc_hi << 8) | bc_lo;

/* shall be cleared to zero, indicating xfer of data */
if (ireason & (1 << 0))
if (unlikely(ireason & (1 << 0)))
goto err_out;

/* make sure transfer direction matches expected */
i_write = ((ireason & (1 << 1)) == 0) ? 1 : 0;
if (do_write != i_write)
if (unlikely(do_write != i_write))
goto err_out;

if (unlikely(!bytes))
goto err_out;

VPRINTK("ata%u: xfering %d bytes\n", ap->print_id, bytes);
Expand Down

0 comments on commit 0106372

Please sign in to comment.