Skip to contentSkip to conversation

drivers: uio_dmem_genirq: Fix memory leak in uio_dmem_genirq_probe()

PATCH In review Daeseok Youn 2 participants 2 messages May 22, 2014 Userspace I/O (UIO)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: uio_dmem_genirq: Fix memory leak in uio_dmem_genirq_probe()

When platform_get_irq() is failed after "priv" allocated, it need to free "priv". But the label of bad0 doesn't try to free about "priv". So this patch changes that lable to "bad1". But "bad1" has pm_runtime_disable() call, this function should be called when uio_register_device() is failed. So it is moved into handling error for uio_register_device().

---
 drivers/uio/uio_dmem_genirq.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/uio/uio_dmem_genirq.c +2 -2
index 1270f3b..8d0bba4 100644
@@ -204,7 +204,7 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 		ret = platform_get_irq(pdev, 0);
 		if (ret < 0) {
 			dev_err(&pdev->dev, "failed to get IRQ\n");
-			goto bad0;
+			goto bad1;
 		}
 		uioinfo->irq = ret;
 	}
@@ -275,6 +275,7 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 	ret = uio_register_device(&pdev->dev, priv->uioinfo);
 	if (ret) {
 		dev_err(&pdev->dev, "unable to register uio device\n");
+		pm_runtime_disable(&pdev->dev);
 		goto bad1;
 	}
 
@@ -282,7 +283,6 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 	return 0;
  bad1:
 	kfree(priv);
-	pm_runtime_disable(&pdev->dev);
  bad0:
 	/* kfree uioinfo for OF */
 	if (pdev->dev.of_node)
Signature · 1 line
1.7.1
#1 lore raw
Quoted 6 lines · Daeseok Youn

When platform_get_irq() is failed after "priv" allocated, it need to free "priv". But the label of bad0 doesn't try to free about "priv". So this patch changes that lable to "bad1". But "bad1" has pm_runtime_disable() call, this function should be called when uio_register_device() is failed. So it is moved into handling error for uio_register_device().

Looks alright to me. Thanks for your contribution.

Quoted 39 lines
---
 drivers/uio/uio_dmem_genirq.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/uio/uio_dmem_genirq.c +2 -2
index 1270f3b..8d0bba4 100644
@@ -204,7 +204,7 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 		ret = platform_get_irq(pdev, 0);
 		if (ret < 0) {
 			dev_err(&pdev->dev, "failed to get IRQ\n");
-			goto bad0;
+			goto bad1;
 		}
 		uioinfo->irq = ret;
 	}
@@ -275,6 +275,7 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 	ret = uio_register_device(&pdev->dev, priv->uioinfo);
 	if (ret) {
 		dev_err(&pdev->dev, "unable to register uio device\n");
+		pm_runtime_disable(&pdev->dev);
 		goto bad1;
 	}
 
@@ -282,7 +283,6 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 	return 0;
  bad1:
 	kfree(priv);
-	pm_runtime_disable(&pdev->dev);
  bad0:
 	/* kfree uioinfo for OF */
 	if (pdev->dev.of_node)
Signature · 1 line
1.7.1