Re: [PATCH AUTOSEL 5.2 154/185] x86/platform/uv: Fix kmalloc() NULL check routine

2019-09-22 Thread Greg KH
On Sun, Sep 22, 2019 at 02:48:52PM -0400, Sasha Levin wrote:
> From: Austin Kim 
> 
> [ Upstream commit 864b23f0169d5bff677e8443a7a90dfd6b090afc ]
> 
> The result of kmalloc() should have been checked ahead of below statement:
> 
>   pqp = (struct bau_pq_entry *)vp;
> 
> Move BUG_ON(!vp) before above statement.
> 
> Signed-off-by: Austin Kim 
> Cc: Dimitri Sivanich 
> Cc: Hedi Berriche 
> Cc: Linus Torvalds 
> Cc: Mike Travis 
> Cc: Peter Zijlstra 
> Cc: Russ Anderson 
> Cc: Steve Wahl 
> Cc: Thomas Gleixner 
> Cc: alli...@lohutok.net
> Cc: a...@infradead.org
> Cc: arm...@tjaldur.nl
> Cc: b...@alien8.de
> Cc: dvh...@infradead.org
> Cc: gre...@linuxfoundation.org
> Cc: h...@zytor.com
> Cc: k...@umn.edu
> Cc: platform-driver-...@vger.kernel.org
> Link: https://lkml.kernel.org/r/20190905232951.GA28779@LGEARND20B15
> Signed-off-by: Ingo Molnar 
> Signed-off-by: Sasha Levin 
> ---
>  arch/x86/platform/uv/tlb_uv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
> index 0c7dfec4acac8..5a66d73620ce4 100644
> --- a/arch/x86/platform/uv/tlb_uv.c
> +++ b/arch/x86/platform/uv/tlb_uv.c
> @@ -1815,9 +1815,9 @@ static void pq_init(int node, int pnode)
>  
>   plsize = (DEST_Q_SIZE + 1) * sizeof(struct bau_pq_entry);
>   vp = kmalloc_node(plsize, GFP_KERNEL, node);
> - pqp = (struct bau_pq_entry *)vp;
> - BUG_ON(!pqp);
> + BUG_ON(!vp);
>  
> + pqp = (struct bau_pq_entry *)vp;
>   cp = (char *)pqp + 31;
>   pqp = (struct bau_pq_entry *)(((unsigned long)cp >> 5) << 5);
>  

Please drop from everywhere.

thanks,

greg k-h


[PATCH AUTOSEL 5.2 154/185] x86/platform/uv: Fix kmalloc() NULL check routine

2019-09-22 Thread Sasha Levin
From: Austin Kim 

[ Upstream commit 864b23f0169d5bff677e8443a7a90dfd6b090afc ]

The result of kmalloc() should have been checked ahead of below statement:

pqp = (struct bau_pq_entry *)vp;

Move BUG_ON(!vp) before above statement.

Signed-off-by: Austin Kim 
Cc: Dimitri Sivanich 
Cc: Hedi Berriche 
Cc: Linus Torvalds 
Cc: Mike Travis 
Cc: Peter Zijlstra 
Cc: Russ Anderson 
Cc: Steve Wahl 
Cc: Thomas Gleixner 
Cc: alli...@lohutok.net
Cc: a...@infradead.org
Cc: arm...@tjaldur.nl
Cc: b...@alien8.de
Cc: dvh...@infradead.org
Cc: gre...@linuxfoundation.org
Cc: h...@zytor.com
Cc: k...@umn.edu
Cc: platform-driver-...@vger.kernel.org
Link: https://lkml.kernel.org/r/20190905232951.GA28779@LGEARND20B15
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 arch/x86/platform/uv/tlb_uv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 0c7dfec4acac8..5a66d73620ce4 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1815,9 +1815,9 @@ static void pq_init(int node, int pnode)
 
plsize = (DEST_Q_SIZE + 1) * sizeof(struct bau_pq_entry);
vp = kmalloc_node(plsize, GFP_KERNEL, node);
-   pqp = (struct bau_pq_entry *)vp;
-   BUG_ON(!pqp);
+   BUG_ON(!vp);
 
+   pqp = (struct bau_pq_entry *)vp;
cp = (char *)pqp + 31;
pqp = (struct bau_pq_entry *)(((unsigned long)cp >> 5) << 5);
 
-- 
2.20.1