Linux driver-core infrastructure
 help / color / mirror / Atom feed
From: Yohei Kojima <yk@y-koj.net>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	driver-core@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] debugfs: warn if file creation failed due to uninitialized debugfs
Date: Sat, 13 Jun 2026 18:45:53 +0900	[thread overview]
Message-ID: <ai0m0atzc0cXT0yQ@desktop.y-koj.net> (raw)
In-Reply-To: <2026061240-cheddar-recolor-63d6@gregkh>

Hi Greg,

Thank you for the response.

On Fri, Jun 12, 2026 at 10:14:34AM +0200, Greg Kroah-Hartman wrote:
> On Thu, Jun 11, 2026 at 10:50:16PM +0900, Yohei Kojima wrote:
> > Improve debugfs_start_creating() to warn if it was used before debugfs
> > initialization. It silently returned ERR_PTR(-ENOENT) before, but it is
> > hard to find the cause of failure especially if it was called by
> > debugfs_create_dir(), because the document of the function says:
> > 
> > > NOTE: it's expected that most callers should _ignore_ the errors returned
> > > by this function. Other debugfs functions handle the fact that the "dentry"
> > > passed to them could be an error and they don't crash in that case.
> > > Drivers should generally work fine even if debugfs fails to init anyway.
> > 
> > Signed-off-by: Yohei Kojima <yk@y-koj.net>
> > ---
> >  fs/debugfs/inode.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
> > index 4598142355b9..e054e62919ec 100644
> > --- a/fs/debugfs/inode.c
> > +++ b/fs/debugfs/inode.c
> > @@ -368,8 +368,11 @@ static struct dentry *debugfs_start_creating(const char *name,
> >  	if (!debugfs_enabled)
> >  		return ERR_PTR(-EPERM);
> >  
> > -	if (!debugfs_initialized())
> > +	if (!debugfs_initialized()) {
> > +		pr_err("Unable to create file '%s', debugfs is not initialized yet\n",
> > +		       name);
> >  		return ERR_PTR(-ENOENT);
> > +	}
> 
> While I understand your frustration when adding new code to the kernel
> that would trigger this, does it actually fail on a normal boot today?

No. As far as I tested, no existing code faied there.

> If not, is this really needed?

At least I want. Also, debugfs_start_creating() already warns if the
caller is trying to create a dentry with the same name of an existing
dentry, which also doesn't happen on a normal boot. The warning for
uninitialized debugfs helps developers avoid pitfalls in the same way.

Thanks,
Yohei

> 
> thanks,
> 
> greg k-h

      reply	other threads:[~2026-06-13  9:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11 13:50 [PATCH] debugfs: warn if file creation failed due to uninitialized debugfs Yohei Kojima
2026-06-12  8:14 ` Greg Kroah-Hartman
2026-06-13  9:45   ` Yohei Kojima [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=ai0m0atzc0cXT0yQ@desktop.y-koj.net \
    --to=yk@y-koj.net \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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