Re: [PATCH] hyperv: a potential NULL pointer dereference
On 3/14/2019 11:16 AM, Kangjie Lu wrote: In case alloc_page, the fix returns -ENOMEM to avoid the potential NULL pointer dereference. Signed-off-by: Kangjie Lu --- 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 7abb09e2eeb8..dfdb4ce1ae9c 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); Looks good to me. Reviewed-by: Mukesh Ojha Thanks. Mukesh
RE: [PATCH] hyperv: a potential NULL pointer dereference
> -Original Message- > From: Thomas Gleixner > Sent: Wednesday, March 20, 2019 3:21 AM > To: KY Srinivasan > Cc: Kangjie Lu ; pakki...@umn.edu; Haiyang Zhang > ; Stephen Hemminger > ; Sasha Levin ; Ingo Molnar > ; Borislav Petkov ; H. Peter Anvin > ; x...@kernel.org; linux-hyp...@vger.kernel.org; linux- > ker...@vger.kernel.org > Subject: RE: [PATCH] hyperv: a potential NULL pointer dereference > > On Thu, 14 Mar 2019, KY Srinivasan wrote: > > > -Original Message- > > > From: Kangjie Lu > > > Sent: Wednesday, March 13, 2019 10:47 PM > > > To: k...@umn.edu > > > Cc: pakki...@umn.edu; KY Srinivasan ; Haiyang > Zhang > > > ; Stephen Hemminger > > > ; Sasha Levin ; Thomas > > > Gleixner ; Ingo Molnar ; > Borislav > > > Petkov ; H. Peter Anvin ; > x...@kernel.org; > > > linux-hyp...@vger.kernel.org; linux-kernel@vger.kernel.org > > > Subject: [PATCH] hyperv: a potential NULL pointer dereference > > > > > > In case alloc_page, the fix returns -ENOMEM to avoid the potential > > > NULL pointer dereference. > > > > > Thanks. > > > > > Signed-off-by: Kangjie Lu > > Signed-off-by: K. Y. Srinivasan > > Did you mean: Reviewed-by or Acked-by? Sorry, I meant Acked-by. K. Y > > You cannot sign off on a patch from > someone else which you are not picking up and transporting it further. > > Thanks, > > tglx
RE: [PATCH] hyperv: a potential NULL pointer dereference
On Thu, 14 Mar 2019, KY Srinivasan wrote: > > -Original Message- > > From: Kangjie Lu > > Sent: Wednesday, March 13, 2019 10:47 PM > > To: k...@umn.edu > > Cc: pakki...@umn.edu; KY Srinivasan ; Haiyang Zhang > > ; Stephen Hemminger > > ; Sasha Levin ; Thomas > > Gleixner ; Ingo Molnar ; Borislav > > Petkov ; H. Peter Anvin ; x...@kernel.org; > > linux-hyp...@vger.kernel.org; linux-kernel@vger.kernel.org > > Subject: [PATCH] hyperv: a potential NULL pointer dereference > > > > In case alloc_page, the fix returns -ENOMEM to avoid the potential > > NULL pointer dereference. > > > Thanks. > > > Signed-off-by: Kangjie Lu > Signed-off-by: K. Y. Srinivasan Did you mean: Reviewed-by or Acked-by? You cannot sign off on a patch from someone else which you are not picking up and transporting it further. Thanks, tglx
RE: [PATCH] hyperv: a potential NULL pointer dereference
> -Original Message- > From: Kangjie Lu > Sent: Wednesday, March 13, 2019 10:47 PM > To: k...@umn.edu > Cc: pakki...@umn.edu; KY Srinivasan ; Haiyang Zhang > ; Stephen Hemminger > ; Sasha Levin ; Thomas > Gleixner ; Ingo Molnar ; Borislav > Petkov ; H. Peter Anvin ; x...@kernel.org; > linux-hyp...@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: [PATCH] hyperv: a potential NULL pointer dereference > > In case alloc_page, the fix returns -ENOMEM to avoid the potential > NULL pointer dereference. > Thanks. > Signed-off-by: Kangjie Lu Signed-off-by: K. Y. Srinivasan > --- > 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 7abb09e2eeb8..dfdb4ce1ae9c 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.17.1
[PATCH] hyperv: a potential NULL pointer dereference
In case alloc_page, the fix returns -ENOMEM to avoid the potential NULL pointer dereference. Signed-off-by: Kangjie Lu --- 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 7abb09e2eeb8..dfdb4ce1ae9c 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.17.1