lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210209110109.906034-1-claudiu.beznea@microchip.com>
Date:   Tue, 9 Feb 2021 13:01:09 +0200
From:   Claudiu Beznea <claudiu.beznea@...rochip.com>
To:     <sre@...nel.org>, <nicolas.ferre@...rochip.com>,
        <alexandre.belloni@...tlin.com>, <ludovic.desroches@...rochip.com>
CC:     <linux-pm@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>,
        Claudiu Beznea <claudiu.beznea@...rochip.com>,
        kernel test robot <lkp@...el.com>,
        "Dan Carpenter" <dan.carpenter@...cle.com>
Subject: [PATCH] power: reset: at91-reset: free resources on exit path

Free resources on exit path (failure path of probe and remove).

Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea@...rochip.com>
---
 drivers/power/reset/at91-reset.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
index 3ff9d93a5226..2ff7833153b6 100644
--- a/drivers/power/reset/at91-reset.c
+++ b/drivers/power/reset/at91-reset.c
@@ -206,7 +206,8 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 			if (!reset->ramc_base[idx]) {
 				dev_err(&pdev->dev, "Could not map ram controller address\n");
 				of_node_put(np);
-				return -ENODEV;
+				ret = -ENODEV;
+				goto unmap;
 			}
 			idx++;
 		}
@@ -218,13 +219,15 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 	reset->args = (u32)match->data;
 
 	reset->sclk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(reset->sclk))
-		return PTR_ERR(reset->sclk);
+	if (IS_ERR(reset->sclk)) {
+		ret = PTR_ERR(reset->sclk);
+		goto unmap;
+	}
 
 	ret = clk_prepare_enable(reset->sclk);
 	if (ret) {
 		dev_err(&pdev->dev, "Could not enable slow clock\n");
-		return ret;
+		goto unmap;
 	}
 
 	platform_set_drvdata(pdev, reset);
@@ -239,21 +242,33 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 	ret = register_restart_handler(&reset->nb);
 	if (ret) {
 		clk_disable_unprepare(reset->sclk);
-		return ret;
+		goto unmap;
 	}
 
 	at91_reset_status(pdev, reset->rstc_base);
 
 	return 0;
+
+unmap:
+	iounmap(reset->rstc_base);
+	for (idx = 0; idx < ARRAY_SIZE(reset->ramc_base); idx++)
+		iounmap(reset->ramc_base[idx]);
+
+	return ret;
 }
 
 static int __exit at91_reset_remove(struct platform_device *pdev)
 {
 	struct at91_reset *reset = platform_get_drvdata(pdev);
+	int idx;
 
 	unregister_restart_handler(&reset->nb);
 	clk_disable_unprepare(reset->sclk);
 
+	iounmap(reset->rstc_base);
+	for (idx = 0; idx < ARRAY_SIZE(reset->ramc_base); idx++)
+		iounmap(reset->ramc_base[idx]);
+
 	return 0;
 }
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ