Skip to contentSkip to conversation

sifive ccache error handling backports for 5.15

PATCH New Conor Dooley 1 participant 4 messages Apr 24, 2023 Stable branch

lore
Share & tools
lore
#0 lore raw

v2 cover sifive ccache error handling backports for 5.15

Following up on:
https://lore.kernel.org/stable/20230412-mustang-machine-e9fccdb6b81c@wendy/

Here's some backports that do pull back the rename of the driver and Kconfig symbol etc.

Changes in v2:
- use the right hash for 2/3

CC Greg Kroah-Hartman <[email protected]>
CC Greentime Hu <[email protected]>
CC Zong Li <[email protected]>
CC Palmer Dabbelt <[email protected]>
CC Sasha Levin <[email protected]>

Yang Yingliang (3):
soc: sifive: l2_cache: fix missing iounmap() in error path in

    sifive_l2_init()
  soc: sifive: l2_cache: fix missing free_irq() in error path in
    sifive_l2_init()

soc: sifive: l2_cache: fix missing of_node_put() in sifive_l2_init()

 drivers/soc/sifive/sifive_l2_cache.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH v2 1/3 soc: sifive: l2_cache: fix missing iounmap() in error path in sifive_l2_init()

From: Yang Yingliang <[email protected]>

commit 73e770f085023da327dc9ffeb6cd96b0bb22d97e upstream.

Add missing iounmap() before return error from sifive_l2_init().

Fixes a967a289f169 ("RISC-V: sifive_l2_cache: Add L2 cache controller driver for SiFive SoCs")
[conor: ccache -> l2_cache]
---
 drivers/soc/sifive/sifive_l2_cache.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/soc/sifive/sifive_l2_cache.c +7 -2
index 59640a1d0b28..483aeaf0d405 100644
@@ -212,7 +212,8 @@ static int __init sifive_l2_init(void)
 	intr_num = of_property_count_u32_elems(np, "interrupts");
 	if (!intr_num) {
 		pr_err("L2CACHE: no interrupts property\n");
-		return -ENODEV;
+		rc = -ENODEV;
+		goto err_unmap;
 	}
 
 	for (i = 0; i < intr_num; i++) {
@@ -220,7 +221,7 @@ static int __init sifive_l2_init(void)
 		rc = request_irq(g_irq[i], l2_int_handler, 0, "l2_ecc", NULL);
 		if (rc) {
 			pr_err("L2CACHE: Could not request IRQ %d\n", g_irq[i]);
-			return rc;
+			goto err_unmap;
 		}
 	}
 
@@ -233,5 +234,9 @@ static int __init sifive_l2_init(void)
 	setup_sifive_debug();
 #endif
 	return 0;
+
+err_unmap:
+	iounmap(l2_base);
+	return rc;
 }
 device_initcall(sifive_l2_init);
Signature · 1 line
2.39.2
#2 lore raw

PATCH v2 2/3 soc: sifive: l2_cache: fix missing free_irq() in error path in sifive_l2_init()

In reply to Conor Dooley

From: Yang Yingliang <[email protected]>

commit 756344e7cb1afbb87da8705c20384dddd0dea233 upstream.

Add missing free_irq() before return error from sifive_l2_init().

Fixes a967a289f169 ("RISC-V: sifive_l2_cache: Add L2 cache controller driver for SiFive SoCs")
[conor: ccache -> l2_cache]
---
 drivers/soc/sifive/sifive_l2_cache.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/soc/sifive/sifive_l2_cache.c +4 -1
index 483aeaf0d405..1248127009f6 100644
@@ -221,7 +221,7 @@ static int __init sifive_l2_init(void)
 		rc = request_irq(g_irq[i], l2_int_handler, 0, "l2_ecc", NULL);
 		if (rc) {
 			pr_err("L2CACHE: Could not request IRQ %d\n", g_irq[i]);
-			goto err_unmap;
+			goto err_free_irq;
 		}
 	}
 
@@ -235,6 +235,9 @@ static int __init sifive_l2_init(void)
 #endif
 	return 0;
 
+err_free_irq:
+	while (--i >= 0)
+		free_irq(g_irq[i], NULL);
 err_unmap:
 	iounmap(l2_base);
 	return rc;
Signature · 1 line
2.39.2
#3 lore raw

PATCH v2 3/3 soc: sifive: l2_cache: fix missing of_node_put() in sifive_l2_init()

In reply to Conor Dooley

From: Yang Yingliang <[email protected]>

commit 8fbf94fea0b4e187ca9100936c5429f96b8a4e44 upstream.

The device_node pointer returned by of_find_matching_node() with refcount incremented, when finish using it, the refcount need be decreased.

Fixes a967a289f169 ("RISC-V: sifive_l2_cache: Add L2 cache controller driver for SiFive SoCs")
[conor: cache -> l2_cache]
---
 drivers/soc/sifive/sifive_l2_cache.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/soc/sifive/sifive_l2_cache.c +11 -4
index 1248127009f6..783158070490 100644
@@ -202,12 +202,16 @@ static int __init sifive_l2_init(void)
 	if (!np)
 		return -ENODEV;
 
-	if (of_address_to_resource(np, 0, &res))
-		return -ENODEV;
+	if (of_address_to_resource(np, 0, &res)) {
+		rc = -ENODEV;
+		goto err_node_put;
+	}
 
 	l2_base = ioremap(res.start, resource_size(&res));
-	if (!l2_base)
-		return -ENOMEM;
+	if (!l2_base) {
+		rc = -ENOMEM;
+		goto err_node_put;
+	}
 
 	intr_num = of_property_count_u32_elems(np, "interrupts");
 	if (!intr_num) {
@@ -224,6 +228,7 @@ static int __init sifive_l2_init(void)
 			goto err_free_irq;
 		}
 	}
+	of_node_put(np);
 
 	l2_config_read();
 
@@ -240,6 +245,8 @@ static int __init sifive_l2_init(void)
 		free_irq(g_irq[i], NULL);
 err_unmap:
 	iounmap(l2_base);
+err_node_put:
+	of_node_put(np);
 	return rc;
 }
 device_initcall(sifive_l2_init);
Signature · 1 line
2.39.2