mm/gup: fix memory leak in __gup_benchmark_ioctl

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().

[ rework code flow, return -EINVAL rather than -1]
Fixes: 714a3a1ebafe ("mm/gup_benchmark.c: add additional pinning methods")
Signed-off-by: Navid Emamdoost <>
Reviewed-by: Andrew Morton <>
Reviewed-by: Ira Weiny <>
Reviewed-by: John Hubbard <>
Cc: Keith Busch <>
Cc: Kirill A. Shutemov <>
Cc: Dave Hansen <>
Cc: Dan Williams <>
Cc: David Hildenbrand <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
1 file changed