From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Arve Hjønnevåg" <arve@android.com>,
"Riley Andrews" <riandrews@android.com>,
"Martijn Coenen" <maco@google.com>,
"John Stultz" <john.stultz@linaro.org>,
"Douglas Anderson" <dianders@chromium.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH] android: binder: check result of binder_get_thread() in binder_poll()
Date: Mon, 8 May 2017 13:43:23 -0700 [thread overview]
Message-ID: <20170508204323.GA28410@dtor-ws> (raw)
If binder_get_thread() fails to give us a thread data, we should avoid
dereferencing a NULL pointer and return POLLERR instead.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/android/binder.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index aae4d8d4be36..66ed714fedd5 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -3103,18 +3103,22 @@ static unsigned int binder_poll(struct file *filp,
struct poll_table_struct *wait)
{
struct binder_proc *proc = filp->private_data;
- struct binder_thread *thread = NULL;
+ struct binder_thread *thread;
int wait_for_proc_work;
binder_lock(__func__);
thread = binder_get_thread(proc);
-
- wait_for_proc_work = thread->transaction_stack == NULL &&
- list_empty(&thread->todo) && thread->return_error == BR_OK;
+ if (thread)
+ wait_for_proc_work = thread->transaction_stack == NULL &&
+ list_empty(&thread->todo) &&
+ thread->return_error == BR_OK;
binder_unlock(__func__);
+ if (!thread)
+ return POLLERR;
+
if (wait_for_proc_work) {
if (binder_has_proc_work(proc, thread))
return POLLIN;
--
2.13.0.rc1.294.g07d810a77f-goog
--
Dmitry
next reply other threads:[~2017-05-08 20:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-08 20:43 Dmitry Torokhov [this message]
2017-05-08 20:46 ` [PATCH] android: binder: check result of binder_get_thread() in binder_poll() John Stultz
2017-05-08 20:56 ` Doug Anderson
2017-08-23 1:50 ` Greg Kroah-Hartman
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=20170508204323.GA28410@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=arve@android.com \
--cc=devel@driverdev.osuosl.org \
--cc=dianders@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maco@google.com \
--cc=riandrews@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.