Linux driver-core infrastructure
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Paul Martin <paul.martin@codethink.co.uk>
Cc: driver-core@lists.linux.dev, rafael@kernel.org, dakr@kernel.org
Subject: Re: [PATCH] Fix debugfs error returns to match documentation and vice versa
Date: Fri, 22 May 2026 13:26:39 +0200	[thread overview]
Message-ID: <2026052214-dime-drudge-479c@gregkh> (raw)
In-Reply-To: <20260506165819.58974-1-paul.martin@codethink.co.uk>

On Wed, May 06, 2026 at 05:58:19PM +0100, Paul Martin wrote:
> Many of debugfs's exported functions call `debugfs_start_creating()`
> and return the errors it returns.  These differ from the documentation
> in that:
> 
> - `ERR_PTR(-EPERM)` is returned if debugfs is present in the kernel
>   but has been disabled by configuration or boot option.
> 
> - `ERR_PTR(-ENOENT)` is returned if debugfs is not registered in the
>   kernel.
> 
> At no point does it return `ERR_PTR(-ENODEV)`.
> 
> This patch fixes the returned error in the second scenario to match
> the documentation and also the documentation to mention the returned
> error for the first scenario.
> 
> The comment block above `debugfs_lookup()` says it returns
> `ERR_PTR(-ENODEV)` if debugfs is not enabled, but instead it returns
> NULL.  This patch fixes the code to match the documentation.
> ---
>  Documentation/filesystems/debugfs.rst |  4 +++-
>  fs/debugfs/inode.c                    | 13 +++++++++++--
>  2 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/filesystems/debugfs.rst b/Documentation/filesystems/debugfs.rst
> index 55f807293924..b092b0015b98 100644
> --- a/Documentation/filesystems/debugfs.rst
> +++ b/Documentation/filesystems/debugfs.rst
> @@ -41,7 +41,9 @@ dentry pointer which can be used to create files in the directory (and to
>  clean it up at the end).  An ERR_PTR(-ERROR) return value indicates that
>  something went wrong.  If ERR_PTR(-ENODEV) is returned, that is an
>  indication that the kernel has been built without debugfs support and none
> -of the functions described below will work.
> +of the functions described below will work.  If ERR_PTR(-EPERM) is returned
> +debugfs support was compiled in but has been disabled by default in the
> +kernel configuration or by passing ``debugfs=off`` on the kernel commandline.
>  
>  The most general way to create a file within a debugfs directory is with::
>  
> diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
> index 4598142355b9..fc521bf9f191 100644
> --- a/fs/debugfs/inode.c
> +++ b/fs/debugfs/inode.c
> @@ -346,7 +346,10 @@ struct dentry *debugfs_lookup(const char *name, struct dentry *parent)
>  {
>  	struct dentry *dentry;
>  
> -	if (!debugfs_initialized() || IS_ERR_OR_NULL(name) || IS_ERR(parent))
> +	if (!debugfs_initialized() || !debugfs_enabled)
> +		return ERR_PTR(-ENODEV);
> +
> +	if (IS_ERR_OR_NULL(name) || IS_ERR(parent))
>  		return NULL;
>  
>  	if (!parent)
> @@ -369,7 +372,7 @@ static struct dentry *debugfs_start_creating(const char *name,
>  		return ERR_PTR(-EPERM);
>  
>  	if (!debugfs_initialized())
> -		return ERR_PTR(-ENOENT);
> +		return ERR_PTR(-ENODEV);
>  
>  	pr_debug("creating file '%s'\n", name);
>  
> @@ -562,6 +565,9 @@ EXPORT_SYMBOL_GPL(debugfs_create_file_size);
>   * If debugfs is not enabled in the kernel, the value -%ENODEV will be
>   * returned.
>   *
> + * If debugfs is enabled in the kernel but disabled by configuration,
> + * the value -%EPERM will be returned.
> + *
>   * 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.
> @@ -659,6 +665,9 @@ EXPORT_SYMBOL(debugfs_create_automount);
>   *
>   * If debugfs is not enabled in the kernel, the value -%ENODEV will be
>   * returned.
> + *
> + * If debugfs is enabled in the kernel but disabled by configuration,
> + * the value -%EPERM will be returned.
>   */
>  struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
>  				      const char *target)
> -- 
> 2.53.0
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch does not have a Signed-off-by: line.  Please read the
  kernel file, Documentation/process/submitting-patches.rst and resend
  it after adding that line.  Note, the line needs to be in the body of
  the email, before the patch, not at the bottom of the patch or in the
  email signature.

- Your patch did many different things all at once, making it difficult
  to review.  All Linux kernel patches need to only do one thing at a
  time.  If you need to do multiple things (such as clean up all coding
  style issues in a file/driver), do it in a sequence of patches, each
  one doing only one thing.  This will make it easier to review the
  patches to ensure that they are correct, and to help alleviate any
  merge issues that larger patches can cause.


If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

      reply	other threads:[~2026-05-22 11:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 16:58 [PATCH] Fix debugfs error returns to match documentation and vice versa Paul Martin
2026-05-22 11:26 ` Greg Kroah-Hartman [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=2026052214-dime-drudge-479c@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=paul.martin@codethink.co.uk \
    --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