From: Jonathan Cameron <jic23@kernel.org>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: Conor Dooley <conor@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>, Paul Walmsley <pjw@kernel.org>,
Samuel Holland <samuel.holland@sifive.com>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] cache: sifive_ccache: remove debugfs on driver register failure
Date: Sat, 15 Aug 2026 02:05:58 +0100 [thread overview]
Message-ID: <20260815020558.2b4adbd9@jic23-huawei> (raw)
In-Reply-To: <20260814081334.25771-1-pengpeng@iscas.ac.cn>
On Fri, 14 Aug 2026 16:13:34 +0800
Pengpeng Hou <pengpeng@iscas.ac.cn> wrote:
> sifive_ccache_init() creates its debugfs entries before registering the
> platform driver. If platform_driver_register() fails, the current error
> path unmaps ccache_base but leaves the debugfs file and its write
> callback reachable.
>
> Remove the debugfs directory on that failure path before unmapping the
> controller registers.
>
> Fixes: c90847bcbfb6 ("cache: sifive_ccache: Partially convert to a platform driver")
>
No blank lines in tag blocks. That breaks a bunch of tooling that
runs on the kernel + tends to get you a message from one
of the bots that is there to prevent this getting merged.
> Assisted-by: Codex:gpt-5
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> Changes since v2: https://lore.kernel.org/all/20260623015527.32846-1-pengpeng@iscas.ac.cn/
> - no source-code changes
> - rebase on current RISC-V sources
> - add the coding-assistant disclosure
>
> The error path was reviewed statically. It was not exercised on SiFive
> hardware.
>
> drivers/cache/sifive_ccache.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cache/sifive_ccache.c b/drivers/cache/sifive_ccache.c
> index 2acb8bdf06d5..3b7a78fc7feb 100644
> --- a/drivers/cache/sifive_ccache.c
> +++ b/drivers/cache/sifive_ccache.c
> @@ -338,12 +338,16 @@ static int __init sifive_ccache_init(void)
>
> rc = platform_driver_register(&sifive_ccache_driver);
> if (rc)
> - goto err_unmap;
> + goto err_remove_debugfs;
>
> of_node_put(np);
>
> return 0;
>
> +err_remove_debugfs:
> +#ifdef CONFIG_DEBUG_FS
It is stubbed out in debugfs.h so no need for guards here.
So for that matter are the creation functions used in here.
Ideally follow this patch with one removing ifdef CONFIG_DEBUG_FS
from the driver. Both calls will return errors but that is
fine as they aren't checked anyway (common for debugfs
as a driver is almost never expected to fail probe just because
debugfs isn't there). Note removing those guards should (feel
free to check) result in no overhead as they dead code should get
removed.
Jonathan
> + debugfs_remove_recursive(sifive_test);
> +#endif
> err_unmap:
> iounmap(ccache_base);
> err_node_put:
prev parent reply other threads:[~2026-08-15 1:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 8:13 Pengpeng Hou
2026-08-15 1:05 ` Jonathan Cameron [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=20260815020558.2b4adbd9@jic23-huawei \
--to=jic23@kernel.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=conor@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pengpeng@iscas.ac.cn \
--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®