From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Leesoo Ahn <lsahn@ooseel.net>
Cc: "Leesoo Ahn" <lsahn@wewakecorp.com>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Martijn Coenen" <maco@android.com>,
"Joel Fernandes" <joel@joelfernandes.org>,
"Christian Brauner" <brauner@kernel.org>,
"Carlos Llamas" <cmllamas@google.com>,
"Suren Baghdasaryan" <surenb@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] android: binder: print error message on failure of creating proc file
Date: Fri, 12 Jul 2024 07:40:37 +0200 [thread overview]
Message-ID: <2024071214-onshore-moonbeam-4eeb@gregkh> (raw)
In-Reply-To: <20240712032140.4012667-1-lsahn@wewakecorp.com>
On Fri, Jul 12, 2024 at 12:21:40PM +0900, Leesoo Ahn wrote:
> It better prints out an error message to give more information if
> calling debugfs_create_file() is failure and the return value has an
> error code.
>
> Signed-off-by: Leesoo Ahn <lsahn@ooseel.net>
> ---
> drivers/android/binder.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index b21a7b246a0d..eb0fd1443d69 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -5673,6 +5673,7 @@ static int binder_open(struct inode *nodp, struct file *filp)
>
> if (binder_debugfs_dir_entry_proc && !existing_pid) {
> char strbuf[11];
> + struct dentry *debugfs_entry;
>
> snprintf(strbuf, sizeof(strbuf), "%u", proc->pid);
> /*
> @@ -5681,10 +5682,19 @@ static int binder_open(struct inode *nodp, struct file *filp)
> * The printing code will anyway print all contexts for a given
> * PID so this is not a problem.
> */
> - proc->debugfs_entry = debugfs_create_file(strbuf, 0444,
> + debugfs_entry = debugfs_create_file(strbuf, 0444,
> binder_debugfs_dir_entry_proc,
> (void *)(unsigned long)proc->pid,
> &proc_fops);
> + if (!IS_ERR(debugfs_entry)) {
> + proc->debugfs_entry = debugfs_entry;
> + } else {
> + int error;
> +
> + error = PTR_ERR(debugfs_entry);
> + pr_warn("Unable to create file %s in debugfs (error %d)\n",
> + strbuf, error);
Even if we wanted to warn about this (hint, you don't, see previous
response), this way to check is incorrect and will fail if debugfs is
not enabled, which you don't want to have happen.
So I'm guessing you did not test this with that config option disabled?
thanks,
greg k-h
next prev parent reply other threads:[~2024-07-12 5:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-12 3:21 [PATCH] android: binder: print error message on failure of creating proc file Leesoo Ahn
2024-07-12 4:01 ` Carlos Llamas
2024-07-12 5:39 ` Greg Kroah-Hartman
2024-07-12 6:52 ` Leesoo Ahn
2024-07-12 7:19 ` Greg Kroah-Hartman
2024-07-12 7:33 ` Leesoo Ahn
2024-07-12 5:40 ` Greg Kroah-Hartman [this message]
2024-07-12 5:54 ` Leesoo Ahn
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=2024071214-onshore-moonbeam-4eeb@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=arve@android.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lsahn@ooseel.net \
--cc=lsahn@wewakecorp.com \
--cc=maco@android.com \
--cc=surenb@google.com \
--cc=tkjos@android.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.