[PATCH 09/10] ide-atapi: protect ide_atapi_pc pointer from ide-cd code path

From: Borislav Petkov
Date: Sun Sep 14 2008 - 07:39:07 EST


... since it is undefined.

There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@xxxxxxxxx>
---
drivers/ide/ide-atapi.c | 27 +++++++++++++++------------
1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 733a75a..45e88a9 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -561,9 +561,16 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,
u16 bcount;
u8 scsi = !!(drive->dev_flags & IDE_DFLAG_SCSI);

- /* We haven't transferred any data yet */
- pc->xferred = 0;
- pc->cur_pos = pc->buf;
+ if (!DEV_IS_IDECD(drive)) {
+ /* We haven't transferred any data yet */
+ pc->xferred = 0;
+ pc->cur_pos = pc->buf;
+
+ if (pc->flags & PC_FLAG_DMA_ERROR) {
+ pc->flags &= ~PC_FLAG_DMA_ERROR;
+ ide_dma_off(drive);
+ }
+ }

/* Request to transfer the entire buffer at once */
if (drive->media == ide_tape && scsi == 0)
@@ -573,14 +580,10 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,
else
bcount = min(pc->req_xfer, 63 * 1024);

- if (pc->flags & PC_FLAG_DMA_ERROR) {
- pc->flags &= ~PC_FLAG_DMA_ERROR;
- ide_dma_off(drive);
- }
-
- if (((pc->flags & PC_FLAG_DMA_OK) &&
- (drive->dev_flags & IDE_DFLAG_USING_DMA)) ||
- (DEV_IS_IDECD(drive) && drive->dma)) {
+ if (drive->dma ||
+ (!DEV_IS_IDECD(drive) &&
+ (pc->flags & PC_FLAG_DMA_OK) &&
+ (drive->dev_flags & IDE_DFLAG_USING_DMA))) {
if (scsi)
hwif->sg_mapped = 1;
drive->dma = !hwif->dma_ops->dma_setup(drive);
@@ -588,7 +591,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,
hwif->sg_mapped = 0;
}

- if (!drive->dma)
+ if (!drive->dma && !DEV_IS_IDECD(drive))
pc->flags &= ~PC_FLAG_DMA_OK;

if (scsi)
--
1.5.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/