mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] soc: versatile: fixes and compile test
@ 2024-08-25 18:05 Krzysztof Kozlowski
  2024-08-25 18:05 ` [PATCH 1/4] soc: versatile: integrator: fix OF node leak in probe() error path Krzysztof Kozlowski
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-25 18:05 UTC (permalink / raw)
  To: Linus Walleij, Arnd Bergmann
  Cc: linux-arm-kernel, linux-kernel, stable, Krzysztof Kozlowski

Hi,

Three fixes for unbinding and error paths.  Enable also compile testing
as cherry on top.

Best regards,
Krzysztof

---
Krzysztof Kozlowski (4):
      soc: versatile: integrator: fix OF node leak in probe() error path
      soc: versatile: realview: fix memory leak during device remove
      soc: versatile: realview: fix soc_dev leak during device remove
      soc: versatile: enable compile testing

 drivers/soc/Makefile                   |  2 +-
 drivers/soc/versatile/Kconfig          |  4 ++--
 drivers/soc/versatile/soc-integrator.c |  1 +
 drivers/soc/versatile/soc-realview.c   | 20 ++++++++++++++++----
 4 files changed, 20 insertions(+), 7 deletions(-)
---
base-commit: 80a76294855640056006e29988f99d46438dcd2b
change-id: 20240825-soc-dev-fixes-ec0889be8379

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>


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

* [PATCH 1/4] soc: versatile: integrator: fix OF node leak in probe() error path
  2024-08-25 18:05 [PATCH 0/4] soc: versatile: fixes and compile test Krzysztof Kozlowski
@ 2024-08-25 18:05 ` Krzysztof Kozlowski
  2024-08-25 18:05 ` [PATCH 2/4] soc: versatile: realview: fix memory leak during device remove Krzysztof Kozlowski
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-25 18:05 UTC (permalink / raw)
  To: Linus Walleij, Arnd Bergmann
  Cc: linux-arm-kernel, linux-kernel, stable, Krzysztof Kozlowski

Driver is leaking OF node reference obtained from
of_find_matching_node().

Fixes: f956a785a282 ("soc: move SoC driver for the ARM Integrator")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/soc/versatile/soc-integrator.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/soc/versatile/soc-integrator.c b/drivers/soc/versatile/soc-integrator.c
index bab4ad87aa75..d5099a3386b4 100644
--- a/drivers/soc/versatile/soc-integrator.c
+++ b/drivers/soc/versatile/soc-integrator.c
@@ -113,6 +113,7 @@ static int __init integrator_soc_init(void)
 		return -ENODEV;
 
 	syscon_regmap = syscon_node_to_regmap(np);
+	of_node_put(np);
 	if (IS_ERR(syscon_regmap))
 		return PTR_ERR(syscon_regmap);
 

-- 
2.43.0


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

* [PATCH 2/4] soc: versatile: realview: fix memory leak during device remove
  2024-08-25 18:05 [PATCH 0/4] soc: versatile: fixes and compile test Krzysztof Kozlowski
  2024-08-25 18:05 ` [PATCH 1/4] soc: versatile: integrator: fix OF node leak in probe() error path Krzysztof Kozlowski
@ 2024-08-25 18:05 ` Krzysztof Kozlowski
  2024-08-25 18:05 ` [PATCH 3/4] soc: versatile: realview: fix soc_dev " Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-25 18:05 UTC (permalink / raw)
  To: Linus Walleij, Arnd Bergmann
  Cc: linux-arm-kernel, linux-kernel, Krzysztof Kozlowski

If device is unbound, the memory allocated for soc_dev_attr should be
freed to prevent leaks.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/soc/versatile/soc-realview.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c
index c6876d232d8f..d304ee69287a 100644
--- a/drivers/soc/versatile/soc-realview.c
+++ b/drivers/soc/versatile/soc-realview.c
@@ -93,7 +93,7 @@ static int realview_soc_probe(struct platform_device *pdev)
 	if (IS_ERR(syscon_regmap))
 		return PTR_ERR(syscon_regmap);
 
-	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
+	soc_dev_attr = devm_kzalloc(&pdev->dev, sizeof(*soc_dev_attr), GFP_KERNEL);
 	if (!soc_dev_attr)
 		return -ENOMEM;
 
@@ -106,10 +106,9 @@ static int realview_soc_probe(struct platform_device *pdev)
 	soc_dev_attr->family = "Versatile";
 	soc_dev_attr->custom_attr_group = realview_groups[0];
 	soc_dev = soc_device_register(soc_dev_attr);
-	if (IS_ERR(soc_dev)) {
-		kfree(soc_dev_attr);
+	if (IS_ERR(soc_dev))
 		return -ENODEV;
-	}
+
 	ret = regmap_read(syscon_regmap, REALVIEW_SYS_ID_OFFSET,
 			  &realview_coreid);
 	if (ret)

-- 
2.43.0


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

* [PATCH 3/4] soc: versatile: realview: fix soc_dev leak during device remove
  2024-08-25 18:05 [PATCH 0/4] soc: versatile: fixes and compile test Krzysztof Kozlowski
  2024-08-25 18:05 ` [PATCH 1/4] soc: versatile: integrator: fix OF node leak in probe() error path Krzysztof Kozlowski
  2024-08-25 18:05 ` [PATCH 2/4] soc: versatile: realview: fix memory leak during device remove Krzysztof Kozlowski
@ 2024-08-25 18:05 ` Krzysztof Kozlowski
  2024-08-25 18:05 ` [PATCH 4/4] soc: versatile: enable compile testing Krzysztof Kozlowski
  2024-08-30 13:40 ` [PATCH 0/4] soc: versatile: fixes and compile test Linus Walleij
  4 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-25 18:05 UTC (permalink / raw)
  To: Linus Walleij, Arnd Bergmann
  Cc: linux-arm-kernel, linux-kernel, stable, Krzysztof Kozlowski

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

Fixes: a2974c9c1f83 ("soc: add driver for the ARM RealView")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/soc/versatile/soc-realview.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c
index d304ee69287a..cf91abe07d38 100644
--- a/drivers/soc/versatile/soc-realview.c
+++ b/drivers/soc/versatile/soc-realview.c
@@ -4,6 +4,7 @@
  *
  * Author: Linus Walleij <linus.walleij@linaro.org>
  */
+#include <linux/device.h>
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/slab.h>
@@ -81,6 +82,13 @@ static struct attribute *realview_attrs[] = {
 
 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)
 {
 	struct regmap *syscon_regmap;
@@ -109,6 +117,11 @@ static int realview_soc_probe(struct platform_device *pdev)
 	if (IS_ERR(soc_dev))
 		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,
 			  &realview_coreid);
 	if (ret)

-- 
2.43.0


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

* [PATCH 4/4] soc: versatile: enable compile testing
  2024-08-25 18:05 [PATCH 0/4] soc: versatile: fixes and compile test Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2024-08-25 18:05 ` [PATCH 3/4] soc: versatile: realview: fix soc_dev " Krzysztof Kozlowski
@ 2024-08-25 18:05 ` Krzysztof Kozlowski
  2024-08-30 13:40 ` [PATCH 0/4] soc: versatile: fixes and compile test Linus Walleij
  4 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-25 18:05 UTC (permalink / raw)
  To: Linus Walleij, Arnd Bergmann
  Cc: linux-arm-kernel, linux-kernel, Krzysztof Kozlowski

Enable compile testing for broader build coverage.  None of the drivers
use anything from "asm", so code should build everywhere.
CONFIG_PLAT_VERSATILE is being selected by driver dependencies
(CONFIG_ARCH_INTEGRATOR and CONFIG_ARCH_REALVIEW), so directory can be
always added to Makefile targets without impacting other configurations.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/soc/Makefile          | 2 +-
 drivers/soc/versatile/Kconfig | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index fb2bd31387d0..56f476a12847 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -32,5 +32,5 @@ obj-y				+= sunxi/
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
 obj-y				+= ti/
 obj-$(CONFIG_ARCH_U8500)	+= ux500/
-obj-$(CONFIG_PLAT_VERSATILE)	+= versatile/
+obj-y				+= versatile/
 obj-y				+= xilinx/
diff --git a/drivers/soc/versatile/Kconfig b/drivers/soc/versatile/Kconfig
index c3792c0a84ac..7bbf54a8d879 100644
--- a/drivers/soc/versatile/Kconfig
+++ b/drivers/soc/versatile/Kconfig
@@ -4,7 +4,7 @@
 #
 config SOC_INTEGRATOR_CM
 	bool "SoC bus device for the ARM Integrator platform core modules"
-	depends on ARCH_INTEGRATOR
+	depends on ARCH_INTEGRATOR || COMPILE_TEST
 	select SOC_BUS
 	help
 	  Include support for the SoC bus on the ARM Integrator platform
@@ -13,7 +13,7 @@ config SOC_INTEGRATOR_CM
 
 config SOC_REALVIEW
 	bool "SoC bus device for the ARM RealView platforms"
-	depends on ARCH_REALVIEW
+	depends on ARCH_REALVIEW || COMPILE_TEST
 	select SOC_BUS
 	help
 	  Include support for the SoC bus on the ARM RealView platforms

-- 
2.43.0


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

* Re: [PATCH 0/4] soc: versatile: fixes and compile test
  2024-08-25 18:05 [PATCH 0/4] soc: versatile: fixes and compile test Krzysztof Kozlowski
                   ` (3 preceding siblings ...)
  2024-08-25 18:05 ` [PATCH 4/4] soc: versatile: enable compile testing Krzysztof Kozlowski
@ 2024-08-30 13:40 ` Linus Walleij
  4 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2024-08-30 13:40 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: Arnd Bergmann, linux-arm-kernel, linux-kernel, stable

On Sun, Aug 25, 2024 at 8:05 PM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:

> Three fixes for unbinding and error paths.  Enable also compile testing
> as cherry on top.

Nice, patches applied. I try to send a PR for them as soon
as possible as well.

Yours,
Linus Walleij

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

end of thread, other threads:[~2024-08-30 13:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-25 18:05 [PATCH 0/4] soc: versatile: fixes and compile test Krzysztof Kozlowski
2024-08-25 18:05 ` [PATCH 1/4] soc: versatile: integrator: fix OF node leak in probe() error path Krzysztof Kozlowski
2024-08-25 18:05 ` [PATCH 2/4] soc: versatile: realview: fix memory leak during device remove Krzysztof Kozlowski
2024-08-25 18:05 ` [PATCH 3/4] soc: versatile: realview: fix soc_dev " Krzysztof Kozlowski
2024-08-25 18:05 ` [PATCH 4/4] soc: versatile: enable compile testing Krzysztof Kozlowski
2024-08-30 13:40 ` [PATCH 0/4] soc: versatile: fixes and compile test Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®