From: Avi Weiss <thnkslprpt@gmail.com>
To: conor@kernel.org
Cc: jic23@kernel.org, pjw@kernel.org, samuel.holland@sifive.com,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
Avi Weiss <thnkslprpt@gmail.com>
Subject: [PATCH v2] cache: sifive_ccache: skip disabled device tree nodes
Date: Tue, 17 Nov 2026 16:23:17 +0200 [thread overview]
Message-ID: <20261117142317.1679285-2-thnkslprpt@gmail.com> (raw)
In-Reply-To: <20261028131939.1014720-2-thnkslprpt@gmail.com>
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@gmail.com>
---
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@gmail.com
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
prev parent reply other threads:[~2026-11-17 14:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 13:19 [PATCH] " Avi Weiss
2026-11-05 18:24 ` Conor Dooley
2026-11-14 17:40 ` Avi
2026-11-16 17:20 ` Conor Dooley
2026-11-17 12:25 ` Avi
2026-11-17 14:23 ` Avi Weiss [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261117142317.1679285-2-thnkslprpt@gmail.com \
--to=thnkslprpt@gmail.com \
--cc=conor@kernel.org \
--cc=jic23@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=pjw@kernel.org \
--cc=samuel.holland@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®