aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/remoteproc/remoteproc_core.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index b6c622982f8c..f163704b6ce5 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -573,17 +573,10 @@ static int rproc_handle_carveout(struct rproc *rproc,
573 dev_dbg(dev, "carveout rsc: da %x, pa %x, len %x, flags %x\n", 573 dev_dbg(dev, "carveout rsc: da %x, pa %x, len %x, flags %x\n",
574 rsc->da, rsc->pa, rsc->len, rsc->flags); 574 rsc->da, rsc->pa, rsc->len, rsc->flags);
575 575
576 mapping = kzalloc(sizeof(*mapping), GFP_KERNEL);
577 if (!mapping) {
578 dev_err(dev, "kzalloc mapping failed\n");
579 return -ENOMEM;
580 }
581
582 carveout = kzalloc(sizeof(*carveout), GFP_KERNEL); 576 carveout = kzalloc(sizeof(*carveout), GFP_KERNEL);
583 if (!carveout) { 577 if (!carveout) {
584 dev_err(dev, "kzalloc carveout failed\n"); 578 dev_err(dev, "kzalloc carveout failed\n");
585 ret = -ENOMEM; 579 return -ENOMEM;
586 goto free_mapping;
587 } 580 }
588 581
589 va = dma_alloc_coherent(dev->parent, rsc->len, &dma, GFP_KERNEL); 582 va = dma_alloc_coherent(dev->parent, rsc->len, &dma, GFP_KERNEL);
@@ -613,11 +606,18 @@ static int rproc_handle_carveout(struct rproc *rproc,
613 * physical address in this case. 606 * physical address in this case.
614 */ 607 */
615 if (rproc->domain) { 608 if (rproc->domain) {
609 mapping = kzalloc(sizeof(*mapping), GFP_KERNEL);
610 if (!mapping) {
611 dev_err(dev, "kzalloc mapping failed\n");
612 ret = -ENOMEM;
613 goto dma_free;
614 }
615
616 ret = iommu_map(rproc->domain, rsc->da, dma, rsc->len, 616 ret = iommu_map(rproc->domain, rsc->da, dma, rsc->len,
617 rsc->flags); 617 rsc->flags);
618 if (ret) { 618 if (ret) {
619 dev_err(dev, "iommu_map failed: %d\n", ret); 619 dev_err(dev, "iommu_map failed: %d\n", ret);
620 goto dma_free; 620 goto free_mapping;
621 } 621 }
622 622
623 /* 623 /*
@@ -662,12 +662,12 @@ static int rproc_handle_carveout(struct rproc *rproc,
662 662
663 return 0; 663 return 0;
664 664
665free_mapping:
666 kfree(mapping);
665dma_free: 667dma_free:
666 dma_free_coherent(dev->parent, rsc->len, va, dma); 668 dma_free_coherent(dev->parent, rsc->len, va, dma);
667free_carv: 669free_carv:
668 kfree(carveout); 670 kfree(carveout);
669free_mapping:
670 kfree(mapping);
671 return ret; 671 return ret;
672} 672}
673 673