Re: [PATCH] mm/gup: Fix memory leak in __gup_benchmark_ioctl
From: Ira Weiny
Date: Thu Dec 12 2019 - 18:15:21 EST
On Wed, Dec 11, 2019 at 11:46:51AM -0600, Navid Emamdoost wrote:
> In the implementation of __gup_benchmark_ioctl() the allocated pages
> should be released before returning in case of an invalid cmd. Release
> pages via kvfree().
>
> Fixes: 714a3a1ebafe ("mm/gup_benchmark.c: add additional pinning methods")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@xxxxxxxxx>
> ---
> mm/gup_benchmark.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/gup_benchmark.c b/mm/gup_benchmark.c
> index 7dd602d7f8db..b160638f647e 100644
> --- a/mm/gup_benchmark.c
> +++ b/mm/gup_benchmark.c
> @@ -63,6 +63,7 @@ static int __gup_benchmark_ioctl(unsigned int cmd,
> NULL);
> break;
> default:
> + kvfree(pages);
I wonder if adding a ret value and a goto where the free is done would be
better. But may be overkill at this time. So...
Reviewed-by: Ira Weiny <ira.weiny@xxxxxxxxx>
> return -1;
> }
>
> --
> 2.17.1
>