mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Conor Dooley <conor@kernel.org>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Paul Walmsley <pjw@kernel.org>,
	Samuel Holland <samuel.holland@sifive.com>,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cache: sifive_ccache: remove debugfs on driver register failure
Date: Tue, 16 Jun 2026 16:29:22 +0100	[thread overview]
Message-ID: <20260616-fossil-labored-ea8b8b08c856@spud> (raw)
In-Reply-To: <20260616151314.87102-1-pengpeng@iscas.ac.cn>

[-- Attachment #1: Type: text/plain, Size: 1892 bytes --]

On Tue, Jun 16, 2026 at 11:13:14PM +0800, Pengpeng Hou wrote:
> sifive_ccache_init() creates the debugfs injection file before
> registering the platform driver. If platform_driver_register() fails, the
> error path unmaps ccache_base while the debugfs file remains and its
> write callback still uses that global mapping.
> 
> Remove the debugfs tree before unmapping the cache controller registers
> on the registration failure path.
> 
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
>  drivers/cache/sifive_ccache.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cache/sifive_ccache.c b/drivers/cache/sifive_ccache.c
> index a86800b123b9..cf7877d8e3e5 100644
> --- a/drivers/cache/sifive_ccache.c
> +++ b/drivers/cache/sifive_ccache.c
> @@ -100,6 +100,12 @@ static void setup_sifive_debug(void)
>  	debugfs_create_file("sifive_debug_inject_error", 0200,
>  			    sifive_test, NULL, &ccache_fops);
>  }
> +
> +static void remove_sifive_debug(void)
> +{
> +	debugfs_remove_recursive(sifive_test);
> +	sifive_test = NULL;

Firstly, do we really need a function for this?
Secondly, is there any reason to actually explicitly NULL this after
we're done removing? The driver has failed to probe so it's not as if
something is going to refer to this dentry pointer anyway?

Am I missing something?


Cheers,
Conor.

> +}
>  #endif
>  
>  static void ccache_config_read(void)
> @@ -336,12 +342,16 @@ static int __init sifive_ccache_init(void)
>  
>  	rc = platform_driver_register(&sifive_ccache_driver);
>  	if (rc)
> -		goto err_unmap;
> +		goto err_remove_debug;
>  
>  	of_node_put(np);
>  
>  	return 0;
>  
> +err_remove_debug:
> +#ifdef CONFIG_DEBUG_FS
> +	remove_sifive_debug();
> +#endif
>  err_unmap:
>  	iounmap(ccache_base);
>  err_node_put:
> -- 
> 2.43.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2026-06-16 15:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 15:13 Pengpeng Hou
2026-06-16 15:29 ` Conor Dooley [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=20260616-fossil-labored-ea8b8b08c856@spud \
    --to=conor@kernel.org \
    --cc=jic23@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --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®