Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1637708 > unrolled thread
| Started by | John Stultz <john.stultz@linaro.org> |
|---|---|
| First post | 2017-05-08 22:50 +0200 |
| Last post | 2017-05-08 23:00 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] android: binder: check result of binder_get_thread() in binder_poll() John Stultz <john.stultz@linaro.org> - 2017-05-08 22:50 +0200
Re: [PATCH] android: binder: check result of binder_get_thread() in binder_poll() Doug Anderson <dianders@chromium.org> - 2017-05-08 23:00 +0200
| From | John Stultz <john.stultz@linaro.org> |
|---|---|
| Date | 2017-05-08 22:50 +0200 |
| Subject | Re: [PATCH] android: binder: check result of binder_get_thread() in binder_poll() |
| Message-ID | <tEXLs-ls-9@gated-at.bofh.it> |
On Mon, May 8, 2017 at 1:43 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> 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>
Pulling Todd Kjos in on this too.
-john
> ---
> 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
[toc] | [next] | [standalone]
| From | Doug Anderson <dianders@chromium.org> |
|---|---|
| Date | 2017-05-08 23:00 +0200 |
| Message-ID | <tEXV7-oX-7@gated-at.bofh.it> |
| In reply to | #1637708 |
Dmitry,
On Mon, May 8, 2017 at 1:46 PM, John Stultz <john.stultz@linaro.org> wrote:
> On Mon, May 8, 2017 at 1:43 PM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
>> 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>
>
> Pulling Todd Kjos in on this too.
> -john
>
>> ---
>> 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;
>> --
I'm no expert on the poll function, but I agree that it's wise to
check the result of binder_get_thread() since it can return NULL.
FWIW:
Reviewed-by: Douglas Anderson <dianders@chromium.org>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web