[PATCH v2] cache: sifive_ccache: skip disabled device tree nodes
From: Avi Weiss
Date: Tue Nov 17 2026 - 09:23:56 EST
sifive_ccache_init() uses of_find_matching_node_and_match(), which may
return a device tree node marked disabled. The driver can then map and
access registers of a cache controller that the device tree marks
unavailable.
Check the selected node's availability before accessing its registers.
Return -ENODEV for a disabled node, releasing the reference through the
existing error path.
Fixes: a967a289f169 ("RISC-V: sifive_l2_cache: Add L2 cache controller driver for SiFive SoCs")
Signed-off-by: Avi Weiss <thnkslprpt@xxxxxxxxx>
---
v2:
- retain the single-node lookup instead of iterating over matches - as
suggested by Conor Dooley
- use the existing error path to release a disabled node
Link to v1: https://lore.kernel.org/r/20261028131939.1014720-2-thnkslprpt@xxxxxxxxx
drivers/cache/sifive_ccache.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/cache/sifive_ccache.c b/drivers/cache/sifive_ccache.c
--- a/drivers/cache/sifive_ccache.c
+++ b/drivers/cache/sifive_ccache.c
@@ -301,6 +301,11 @@ static int __init sifive_ccache_init(void)
if (!np)
return -ENODEV;
+ if (!of_device_is_available(np)) {
+ rc = -ENODEV;
+ goto err_node_put;
+ }
+
quirks = (uintptr_t)match->data;
if (of_address_to_resource(np, 0, &res)) {
--
2.47.3