Commit 5250c969 authored by Richard Cochran's avatar Richard Cochran Committed by David S. Miller

cpsw: fix leaking IO mappings

The CPSW driver remaps two different IO regions, but fails to unmap them
both. This patch fixes the issue by calling iounmap in the appropriate
places.
Signed-off-by: default avatarRichard Cochran <richardcochran@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a65dd5b2
...@@ -1252,14 +1252,12 @@ static int __devinit cpsw_probe(struct platform_device *pdev) ...@@ -1252,14 +1252,12 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
ret = -ENOENT; ret = -ENOENT;
goto clean_clk_ret; goto clean_clk_ret;
} }
if (!request_mem_region(priv->cpsw_res->start, if (!request_mem_region(priv->cpsw_res->start,
resource_size(priv->cpsw_res), ndev->name)) { resource_size(priv->cpsw_res), ndev->name)) {
dev_err(priv->dev, "failed request i/o region\n"); dev_err(priv->dev, "failed request i/o region\n");
ret = -ENXIO; ret = -ENXIO;
goto clean_clk_ret; goto clean_clk_ret;
} }
regs = ioremap(priv->cpsw_res->start, resource_size(priv->cpsw_res)); regs = ioremap(priv->cpsw_res->start, resource_size(priv->cpsw_res));
if (!regs) { if (!regs) {
dev_err(priv->dev, "unable to map i/o region\n"); dev_err(priv->dev, "unable to map i/o region\n");
...@@ -1274,16 +1272,14 @@ static int __devinit cpsw_probe(struct platform_device *pdev) ...@@ -1274,16 +1272,14 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
if (!priv->cpsw_wr_res) { if (!priv->cpsw_wr_res) {
dev_err(priv->dev, "error getting i/o resource\n"); dev_err(priv->dev, "error getting i/o resource\n");
ret = -ENOENT; ret = -ENOENT;
goto clean_clk_ret; goto clean_iomap_ret;
} }
if (!request_mem_region(priv->cpsw_wr_res->start, if (!request_mem_region(priv->cpsw_wr_res->start,
resource_size(priv->cpsw_wr_res), ndev->name)) { resource_size(priv->cpsw_wr_res), ndev->name)) {
dev_err(priv->dev, "failed request i/o region\n"); dev_err(priv->dev, "failed request i/o region\n");
ret = -ENXIO; ret = -ENXIO;
goto clean_clk_ret; goto clean_iomap_ret;
} }
regs = ioremap(priv->cpsw_wr_res->start, regs = ioremap(priv->cpsw_wr_res->start,
resource_size(priv->cpsw_wr_res)); resource_size(priv->cpsw_wr_res));
if (!regs) { if (!regs) {
...@@ -1326,7 +1322,7 @@ static int __devinit cpsw_probe(struct platform_device *pdev) ...@@ -1326,7 +1322,7 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
if (!priv->dma) { if (!priv->dma) {
dev_err(priv->dev, "error initializing dma\n"); dev_err(priv->dev, "error initializing dma\n");
ret = -ENOMEM; ret = -ENOMEM;
goto clean_iomap_ret; goto clean_wr_iomap_ret;
} }
priv->txch = cpdma_chan_create(priv->dma, tx_chan_num(0), priv->txch = cpdma_chan_create(priv->dma, tx_chan_num(0),
...@@ -1407,11 +1403,13 @@ static int __devinit cpsw_probe(struct platform_device *pdev) ...@@ -1407,11 +1403,13 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
cpdma_chan_destroy(priv->txch); cpdma_chan_destroy(priv->txch);
cpdma_chan_destroy(priv->rxch); cpdma_chan_destroy(priv->rxch);
cpdma_ctlr_destroy(priv->dma); cpdma_ctlr_destroy(priv->dma);
clean_iomap_ret: clean_wr_iomap_ret:
iounmap(priv->regs); iounmap(priv->wr_regs);
clean_cpsw_wr_iores_ret: clean_cpsw_wr_iores_ret:
release_mem_region(priv->cpsw_wr_res->start, release_mem_region(priv->cpsw_wr_res->start,
resource_size(priv->cpsw_wr_res)); resource_size(priv->cpsw_wr_res));
clean_iomap_ret:
iounmap(priv->regs);
clean_cpsw_iores_ret: clean_cpsw_iores_ret:
release_mem_region(priv->cpsw_res->start, release_mem_region(priv->cpsw_res->start,
resource_size(priv->cpsw_res)); resource_size(priv->cpsw_res));
...@@ -1442,6 +1440,7 @@ static int __devexit cpsw_remove(struct platform_device *pdev) ...@@ -1442,6 +1440,7 @@ static int __devexit cpsw_remove(struct platform_device *pdev)
iounmap(priv->regs); iounmap(priv->regs);
release_mem_region(priv->cpsw_res->start, release_mem_region(priv->cpsw_res->start,
resource_size(priv->cpsw_res)); resource_size(priv->cpsw_res));
iounmap(priv->wr_regs);
release_mem_region(priv->cpsw_wr_res->start, release_mem_region(priv->cpsw_wr_res->start,
resource_size(priv->cpsw_wr_res)); resource_size(priv->cpsw_wr_res));
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
......
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