Commit c774f256 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Linus Walleij

soc: versatile: realview: fix soc_dev leak during device remove

If device is unbound, the soc_dev should be unregistered to prevent
memory leak.

Fixes: a2974c9c ("soc: add driver for the ARM RealView")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/20240825-soc-dev-fixes-v1-3-ff4b35abed83@linaro.orgSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 1c4f26a4
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* *
* Author: Linus Walleij <linus.walleij@linaro.org> * Author: Linus Walleij <linus.walleij@linaro.org>
*/ */
#include <linux/device.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -81,6 +82,13 @@ static struct attribute *realview_attrs[] = { ...@@ -81,6 +82,13 @@ static struct attribute *realview_attrs[] = {
ATTRIBUTE_GROUPS(realview); ATTRIBUTE_GROUPS(realview);
static void realview_soc_socdev_release(void *data)
{
struct soc_device *soc_dev = data;
soc_device_unregister(soc_dev);
}
static int realview_soc_probe(struct platform_device *pdev) static int realview_soc_probe(struct platform_device *pdev)
{ {
struct regmap *syscon_regmap; struct regmap *syscon_regmap;
...@@ -109,6 +117,11 @@ static int realview_soc_probe(struct platform_device *pdev) ...@@ -109,6 +117,11 @@ static int realview_soc_probe(struct platform_device *pdev)
if (IS_ERR(soc_dev)) if (IS_ERR(soc_dev))
return -ENODEV; return -ENODEV;
ret = devm_add_action_or_reset(&pdev->dev, realview_soc_socdev_release,
soc_dev);
if (ret)
return ret;
ret = regmap_read(syscon_regmap, REALVIEW_SYS_ID_OFFSET, ret = regmap_read(syscon_regmap, REALVIEW_SYS_ID_OFFSET,
&realview_coreid); &realview_coreid);
if (ret) if (ret)
......
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