percpu: fix pcpu_alloc_pages() failure path
authorTejun Heo <tj@kernel.org>
Fri, 15 Aug 2014 20:06:06 +0000 (16:06 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 5 Oct 2014 21:52:20 +0000 (14:52 -0700)
commit6d5d76b07571706adc73e02a6e0d72a6749ddc83
treee34c17636c19eedb9559d75b257d4f72a28f8e96
parentb25d2579bfd58c46fe23452d32cdd8943041cb77
percpu: fix pcpu_alloc_pages() failure path

commit f0d279654dea22b7a6ad34b9334aee80cda62cde upstream.

When pcpu_alloc_pages() fails midway, pcpu_free_pages() is invoked to
free what has already been allocated.  The invocation is across the
whole requested range and pcpu_free_pages() will try to free all
non-NULL pages; unfortunately, this is incorrect as
pcpu_get_pages_and_bitmap(), unlike what its comment suggests, doesn't
clear the pages array and thus the array may have entries from the
previous invocations making the partial failure path free incorrect
pages.

Fix it by open-coding the partial freeing of the already allocated
pages.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/percpu-vm.c