linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc: brcmstb: Unmap sun_top_ctrl_base on errors
@ 2016-04-25 23:08 Florian Fainelli
  2016-04-25 23:14 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2016-04-25 23:08 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: arnd, Florian Fainelli, Brian Norris, Gregory Fong, Justin Chen,
	open list:BROADCOM BCM7XXX ARM ARCHITECTURE, open list

Do not leak a ioremap()'d cookie around, unmaping it in case of errors

Fixes: cef4bafcea2c ("soc: brcmstb: add SoC driver to brcmstb")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Arnd,

Feel free to squash this one and your patch into the original commit, thanks!

 drivers/soc/brcmstb/common.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/brcmstb/common.c b/drivers/soc/brcmstb/common.c
index daf86acf9d01..94e7335553f4 100644
--- a/drivers/soc/brcmstb/common.c
+++ b/drivers/soc/brcmstb/common.c
@@ -51,6 +51,7 @@ static int __init brcmstb_soc_device_init(void)
 	struct soc_device *soc_dev;
 	struct device_node *sun_top_ctrl;
 	void __iomem *sun_top_ctrl_base;
+	int ret = 0;
 
 	sun_top_ctrl = of_find_matching_node(NULL, sun_top_ctrl_match);
 	if (!sun_top_ctrl)
@@ -64,8 +65,10 @@ static int __init brcmstb_soc_device_init(void)
 	product_id = readl(sun_top_ctrl_base + 0x4);
 
 	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
-	if (!soc_dev_attr)
-		return -ENOMEM;
+	if (!soc_dev_attr) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
 	soc_dev_attr->family = kasprintf(GFP_KERNEL, "%x",
 					 family_id >> 28 ?
@@ -83,9 +86,14 @@ static int __init brcmstb_soc_device_init(void)
 		kfree(soc_dev_attr->soc_id);
 		kfree(soc_dev_attr->revision);
 		kfree(soc_dev_attr);
-		return -ENODEV;
+		ret = -ENODEV;
+		goto out;
 	}
 
 	return 0;
+
+out:
+	iounmap(sun_top_ctrl_base);
+	return ret;
 }
 arch_initcall(brcmstb_soc_device_init);
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] soc: brcmstb: Unmap sun_top_ctrl_base on errors
  2016-04-25 23:08 [PATCH] soc: brcmstb: Unmap sun_top_ctrl_base on errors Florian Fainelli
@ 2016-04-25 23:14 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2016-04-25 23:14 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: linux-arm-kernel, Brian Norris, Gregory Fong, Justin Chen,
	open list:BROADCOM BCM7XXX ARM ARCHITECTURE, open list

On Monday 25 April 2016 16:08:09 Florian Fainelli wrote:
> Do not leak a ioremap()'d cookie around, unmaping it in case of errors
> 
> Fixes: cef4bafcea2c ("soc: brcmstb: add SoC driver to brcmstb")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

I've applied it on top now, along with my fix, thanks!

	Arnd

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-25 23:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-25 23:08 [PATCH] soc: brcmstb: Unmap sun_top_ctrl_base on errors Florian Fainelli
2016-04-25 23:14 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).