[ Upstream commit 534c89c22e26b183d838294f0937ee092c82ad3a ] The page allocation in hv_cpu_init() can fail, but the code does not have a check for that.
Add a check and return -ENOMEM when the allocation fails. [ tglx: Massaged changelog ] Signed-off-by: Kangjie Lu <k...@umn.edu> Signed-off-by: Thomas Gleixner <t...@linutronix.de> Reviewed-by: Mukesh Ojha <mo...@codeaurora.org> Acked-by: "K. Y. Srinivasan" <k...@microsoft.com> Cc: pakki...@umn.edu Cc: Haiyang Zhang <haiya...@microsoft.com> Cc: Stephen Hemminger <sthem...@microsoft.com> Cc: Sasha Levin <sas...@kernel.org> Cc: Borislav Petkov <b...@alien8.de> Cc: "H. Peter Anvin" <h...@zytor.com> Cc: linux-hyp...@vger.kernel.org Link: https://lkml.kernel.org/r/20190314054651.1315-1-k...@umn.edu Signed-off-by: Sasha Levin <sas...@kernel.org> --- arch/x86/hyperv/hv_init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index d3f42b6bbdac..8a9cff1f129d 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -102,9 +102,13 @@ static int hv_cpu_init(unsigned int cpu) u64 msr_vp_index; struct hv_vp_assist_page **hvp = &hv_vp_assist_page[smp_processor_id()]; void **input_arg; + struct page *pg; input_arg = (void **)this_cpu_ptr(hyperv_pcpu_input_arg); - *input_arg = page_address(alloc_page(GFP_KERNEL)); + pg = alloc_page(GFP_KERNEL); + if (unlikely(!pg)) + return -ENOMEM; + *input_arg = page_address(pg); hv_get_vp_index(msr_vp_index); -- 2.19.1