* [PATCH] x86/platform/uv: move kmalloc() NULL check routine
@ 2019-09-05 23:29 ` Austin Kim
0 siblings, 0 replies; 5+ messages in thread
From: Austin Kim @ 2019-09-05 23:29 UTC (permalink / raw)
To: tglx, mingo, bp, x86
Cc: dvhart, andy, hpa, x86, gregkh, allison, armijn, kjlu,
platform-driver-x86, linux-kernel
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@gmail.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);
+ pqp = (struct bau_pq_entry *)vp;
cp = (char *)pqp + 31;
pqp = (struct bau_pq_entry *)(((unsigned long)cp >> 5) << 5);
--
2.6.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] x86/platform/uv: move kmalloc() NULL check routine
@ 2019-09-05 23:29 ` Austin Kim
0 siblings, 0 replies; 5+ messages in thread
From: Austin Kim @ 2019-09-05 23:29 UTC (permalink / raw)
To: tglx, mingo, bp
Cc: dvhart, andy, hpa, x86, gregkh, allison, armijn, kjlu,
platform-driver-x86, linux-kernel
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@gmail.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);
+ pqp = (struct bau_pq_entry *)vp;
cp = (char *)pqp + 31;
pqp = (struct bau_pq_entry *)(((unsigned long)cp >> 5) << 5);
--
2.6.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/platform/uv: move kmalloc() NULL check routine
2019-09-05 23:29 ` Austin Kim
(?)
@ 2019-09-06 9:32 ` Greg KH
2019-09-06 10:43 ` Peter Zijlstra
-1 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2019-09-06 9:32 UTC (permalink / raw)
To: Austin Kim
Cc: tglx, mingo, bp, x86, dvhart, andy, hpa, allison, armijn, kjlu,
platform-driver-x86, linux-kernel
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@gmail.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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/platform/uv: move kmalloc() NULL check routine
2019-09-06 9:32 ` Greg KH
@ 2019-09-06 10:43 ` Peter Zijlstra
2019-09-06 10:53 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2019-09-06 10:43 UTC (permalink / raw)
To: Greg KH
Cc: Austin Kim, tglx, mingo, bp, x86, dvhart, andy, hpa, allison,
armijn, kjlu, platform-driver-x86, linux-kernel
On Fri, Sep 06, 2019 at 11:32:52AM +0200, Greg KH wrote:
> 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@gmail.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.
This is boot time init; if memory allocation fails, we're in trouble, no
way forward no way back.
It is not uncommon to have BUG_ON() for alloc failing during boot.
> 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.
Agreed, the patch seems entirely pointless.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/platform/uv: move kmalloc() NULL check routine
2019-09-06 10:43 ` Peter Zijlstra
@ 2019-09-06 10:53 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2019-09-06 10:53 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Austin Kim, tglx, mingo, bp, x86, dvhart, andy, hpa, allison,
armijn, kjlu, platform-driver-x86, linux-kernel
On Fri, Sep 06, 2019 at 12:43:41PM +0200, Peter Zijlstra wrote:
> On Fri, Sep 06, 2019 at 11:32:52AM +0200, Greg KH wrote:
> > 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@gmail.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.
>
> This is boot time init; if memory allocation fails, we're in trouble, no
> way forward no way back.
>
> It is not uncommon to have BUG_ON() for alloc failing during boot.
Hey, how come you get to get away with this here, and in the tty layer I
had to do all sorts of foolish things just for the same "impossible"
thing because syzbot found a way to emulate such lunacy?
Just you wait until the fuzzers get ahold of this code... :)
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-09-06 10:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05 23:29 [PATCH] x86/platform/uv: move kmalloc() NULL check routine Austin Kim
2019-09-05 23:29 ` Austin Kim
2019-09-06 9:32 ` Greg KH
2019-09-06 10:43 ` Peter Zijlstra
2019-09-06 10:53 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.