[PATCH] staging: android: ion: Check for register_shrinker() failure.

Greg KH greg at kroah.com
Wed Dec 6 09:04:24 UTC 2017


On Wed, Nov 29, 2017 at 10:33:39PM +0900, Tetsuo Handa wrote:
> register_shrinker() might return -ENOMEM error since Linux 3.12.
> But since callers of ion_device_add_heap() are not ready to receive an
> error and it is not simple enough to fix within this patch, this patch
> just prints a warning line when register_shrinker() failed.
> 
> Signed-off-by: Tetsuo Handa <penguin-kernel at I-love.SAKURA.ne.jp>
> Cc: John Stultz <john.stultz at linaro.org>
> Cc: Greg Kroah-Hartman <gregkh at suse.de>
> Cc: Michal Hocko <mhocko at suse.com>
> ---
>  drivers/staging/android/ion/ion_heap.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c
> index 91faa7f..56dcbd8 100644
> --- a/drivers/staging/android/ion/ion_heap.c
> +++ b/drivers/staging/android/ion/ion_heap.c
> @@ -312,5 +312,6 @@ void ion_heap_init_shrinker(struct ion_heap *heap)
>  	heap->shrinker.scan_objects = ion_heap_shrink_scan;
>  	heap->shrinker.seeks = DEFAULT_SEEKS;
>  	heap->shrinker.batch = 0;
> -	register_shrinker(&heap->shrinker);
> +	if (register_shrinker(&heap->shrinker))
> +		pr_err("Failed to create heap shrinker for %s\n", heap->name);

Shouldn't you fail the init function here?

Just reporting the issue isn't going to help anyone.

thanks,

greg k-h


More information about the devel mailing list