[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190906093252.GB16843@kroah.com>
Date: Fri, 6 Sep 2019 11:32:52 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Austin Kim <austindh.kim@...il.com>
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, x86@...nel.org,
dvhart@...radead.org, andy@...radead.org, hpa@...or.com,
allison@...utok.net, armijn@...ldur.nl, kjlu@....edu,
platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/platform/uv: move kmalloc() NULL check routine
On Fri, Sep 06, 2019 at 08:29:51AM +0900, Austin Kim wrote:
> 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 <austindh.kim@...il.com>
> ---
> 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 20c389a..5f0a96bf 100644
> --- a/arch/x86/platform/uv/tlb_uv.c
> +++ b/arch/x86/platform/uv/tlb_uv.c
> @@ -1804,9 +1804,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);
Ick! Don't crash the whole machine if you are out of memory, that's a
totally lazy and broken driver. Fix this up properly please.
But the original code is just fine (from a this is doing what I want it
to do point of view), I don't see the need to change anything here, you
did not modify any logic at all.
thanks,
greg k-h
Powered by blists - more mailing lists