Commit 537a95d9 authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik

[libata] restore sg on DMA mapping failure

parent fecb4a0c
...@@ -2622,8 +2622,11 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) ...@@ -2622,8 +2622,11 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt, dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt,
sg->length, dir); sg->length, dir);
if (dma_mapping_error(dma_address)) if (dma_mapping_error(dma_address)) {
/* restore sg */
sg->length += qc->pad_len;
return -1; return -1;
}
sg_dma_address(sg) = dma_address; sg_dma_address(sg) = dma_address;
sg_dma_len(sg) = sg->length; sg_dma_len(sg) = sg->length;
...@@ -2694,8 +2697,11 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) ...@@ -2694,8 +2697,11 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
dir = qc->dma_dir; dir = qc->dma_dir;
n_elem = dma_map_sg(ap->host_set->dev, sg, qc->n_elem, dir); n_elem = dma_map_sg(ap->host_set->dev, sg, qc->n_elem, dir);
if (n_elem < 1) if (n_elem < 1) {
/* restore last sg */
lsg->length += qc->pad_len;
return -1; return -1;
}
DPRINTK("%d sg elements mapped\n", n_elem); DPRINTK("%d sg elements mapped\n", n_elem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment