aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2006-01-22 23:09:36 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-01-26 22:33:50 -0500
commit8e436af9326f5cc2e07d76505154ffddfb04b485 (patch)
tree26d5a6716ff3c164613811a78e5a06c353d28fe3
parent77853bf2b48e34449e826a9ef4df5ea0dbe947f4 (diff)
[PATCH] libata: fix ata_qc_issue() error handling
When ata_qc_issue() fails, the qc might have been dma mapped or not. So, performing only ata_qc_free() results in dma map leak. This patch makes ata_qc_issue() mark dma map flags correctly on failure and calls ata_qc_complete() after ata_qc_issue() fails. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
-rw-r--r--drivers/scsi/libata-core.c18
-rw-r--r--drivers/scsi/libata-scsi.c6
2 files changed, 12 insertions, 12 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 15df633521d0..43a23286d6fe 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1125,8 +1125,10 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
1125 qc->private_data = &wait; 1125 qc->private_data = &wait;
1126 qc->complete_fn = ata_qc_complete_internal; 1126 qc->complete_fn = ata_qc_complete_internal;
1127 1127
1128 if (ata_qc_issue(qc)) 1128 if (ata_qc_issue(qc)) {
1129 goto issue_fail; 1129 qc->err_mask = AC_ERR_OTHER;
1130 ata_qc_complete(qc);
1131 }
1130 1132
1131 spin_unlock_irqrestore(&ap->host_set->lock, flags); 1133 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1132 1134
@@ -1155,11 +1157,6 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
1155 ata_qc_free(qc); 1157 ata_qc_free(qc);
1156 1158
1157 return err_mask; 1159 return err_mask;
1158
1159 issue_fail:
1160 ata_qc_free(qc);
1161 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1162 return AC_ERR_OTHER;
1163} 1160}
1164 1161
1165/** 1162/**
@@ -3687,10 +3684,10 @@ int ata_qc_issue(struct ata_queued_cmd *qc)
3687 if (ata_should_dma_map(qc)) { 3684 if (ata_should_dma_map(qc)) {
3688 if (qc->flags & ATA_QCFLAG_SG) { 3685 if (qc->flags & ATA_QCFLAG_SG) {
3689 if (ata_sg_setup(qc)) 3686 if (ata_sg_setup(qc))
3690 goto err_out; 3687 goto sg_err;
3691 } else if (qc->flags & ATA_QCFLAG_SINGLE) { 3688 } else if (qc->flags & ATA_QCFLAG_SINGLE) {
3692 if (ata_sg_setup_one(qc)) 3689 if (ata_sg_setup_one(qc))
3693 goto err_out; 3690 goto sg_err;
3694 } 3691 }
3695 } else { 3692 } else {
3696 qc->flags &= ~ATA_QCFLAG_DMAMAP; 3693 qc->flags &= ~ATA_QCFLAG_DMAMAP;
@@ -3703,7 +3700,8 @@ int ata_qc_issue(struct ata_queued_cmd *qc)
3703 3700
3704 return ap->ops->qc_issue(qc); 3701 return ap->ops->qc_issue(qc);
3705 3702
3706err_out: 3703sg_err:
3704 qc->flags &= ~ATA_QCFLAG_DMAMAP;
3707 return -1; 3705 return -1;
3708} 3706}
3709 3707
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index ce3fe928a386..c496309f691a 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -1322,8 +1322,10 @@ static void ata_scsi_translate(struct ata_port *ap, struct ata_device *dev,
1322 goto early_finish; 1322 goto early_finish;
1323 1323
1324 /* select device, send command to hardware */ 1324 /* select device, send command to hardware */
1325 if (ata_qc_issue(qc)) 1325 if (ata_qc_issue(qc)) {
1326 goto err_did; 1326 qc->err_mask |= AC_ERR_OTHER;
1327 ata_qc_complete(qc);
1328 }
1327 1329
1328 VPRINTK("EXIT\n"); 1330 VPRINTK("EXIT\n");
1329 return; 1331 return;