[PATCH] android: binder: Check for errors in binder_alloc_shrinker_init().

Sherry Yang sherryy at android.com
Wed Dec 6 19:05:58 UTC 2017


Hi Tetsuo,

It looks like this patch was not submitted to LKML. Perhaps you want
to send it to the mailing list and add the correct set of recipients
using scripts/get_maintainer.pl as suggested here
https://www.kernel.org/doc/html/v4.12/process/submitting-patches.html.

-Sherry

On Wed, Nov 29, 2017 at 8:29 AM, Tetsuo Handa
<penguin-kernel at i-love.sakura.ne.jp> wrote:
> Both list_lru_init() and register_shrinker() might return an error.
>
> Signed-off-by: Tetsuo Handa <penguin-kernel at I-love.SAKURA.ne.jp>
> Cc: Sherry Yang <sherryy at android.com>
> Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
> Cc: Michal Hocko <mhocko at suse.com>
> ---
>  drivers/android/binder.c       |  4 +++-
>  drivers/android/binder_alloc.c | 12 +++++++++---
>  drivers/android/binder_alloc.h |  2 +-
>  3 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 85b0bb4..a54a0f1 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -5569,7 +5569,9 @@ static int __init binder_init(void)
>         struct binder_device *device;
>         struct hlist_node *tmp;
>
> -       binder_alloc_shrinker_init();
> +       ret = binder_alloc_shrinker_init();
> +       if (ret)
> +               return ret;
>
>         atomic_set(&binder_transaction_log.cur, ~0U);
>         atomic_set(&binder_transaction_log_failed.cur, ~0U);
> diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
> index 0dba2308..fdf9d9f 100644
> --- a/drivers/android/binder_alloc.c
> +++ b/drivers/android/binder_alloc.c
> @@ -1006,8 +1006,14 @@ void binder_alloc_init(struct binder_alloc *alloc)
>         INIT_LIST_HEAD(&alloc->buffers);
>  }
>
> -void binder_alloc_shrinker_init(void)
> +int binder_alloc_shrinker_init(void)
>  {
> -       list_lru_init(&binder_alloc_lru);
> -       register_shrinker(&binder_shrinker);
> +       int ret = list_lru_init(&binder_alloc_lru);
> +
> +       if (ret == 0) {
> +               ret = register_shrinker(&binder_shrinker);
> +               if (ret)
> +                       list_lru_destroy(&binder_alloc_lru);
> +       }
> +       return ret;
>  }
> diff --git a/drivers/android/binder_alloc.h b/drivers/android/binder_alloc.h
> index 0b14530..9ef64e5 100644
> --- a/drivers/android/binder_alloc.h
> +++ b/drivers/android/binder_alloc.h
> @@ -130,7 +130,7 @@ extern struct binder_buffer *binder_alloc_new_buf(struct binder_alloc *alloc,
>                                                   size_t extra_buffers_size,
>                                                   int is_async);
>  extern void binder_alloc_init(struct binder_alloc *alloc);
> -void binder_alloc_shrinker_init(void);
> +extern int binder_alloc_shrinker_init(void);
>  extern void binder_alloc_vma_close(struct binder_alloc *alloc);
>  extern struct binder_buffer *
>  binder_alloc_prepare_to_free(struct binder_alloc *alloc,
> --
> 1.8.3.1
>


More information about the devel mailing list