* [PATCH 0/1] omap: Ptr "isr_reg" tracked as NULL was dereferenced
@ 2010-10-05 8:42 Evgeny Kuznetsov
2010-10-05 8:42 ` [PATCH 1/1] " Evgeny Kuznetsov
0 siblings, 1 reply; 8+ messages in thread
From: Evgeny Kuznetsov @ 2010-10-05 8:42 UTC (permalink / raw)
To: tony
Cc: linux-omap, linux-kernel, khilman, akpm, zmc, a.j.buxton,
ext-eugeny.kuznetsov
Hi,
Here is patch which fixes bug in /arch/arm/plat-omap/gpio.c file.
Pointer which may have NULL value in some cases (depend on kernel
configuration and GPIO method) is dereferenced later in code.
If pointer is NULL it mean some kernel bug.
Thanks,
Best Regards,
Evgeny
Evgeny Kuznetsov (1):
omap: Ptr "isr_reg" tracked as NULL was dereferenced
arch/arm/plat-omap/gpio.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/1] omap: Ptr "isr_reg" tracked as NULL was dereferenced
2010-10-05 8:42 [PATCH 0/1] omap: Ptr "isr_reg" tracked as NULL was dereferenced Evgeny Kuznetsov
@ 2010-10-05 8:42 ` Evgeny Kuznetsov
2010-10-05 9:32 ` Felipe Balbi
0 siblings, 1 reply; 8+ messages in thread
From: Evgeny Kuznetsov @ 2010-10-05 8:42 UTC (permalink / raw)
To: tony
Cc: linux-omap, linux-kernel, khilman, akpm, zmc, a.j.buxton,
ext-eugeny.kuznetsov
From: Evgeny Kuznetsov <ext-eugeny.kuznetsov@nokia.com>
Value of "isr_reg" pointer is depend on configuration and GPIO method.
Potentially it may have NULL value and it is dereferenced later
in code. If pointer is NULL there is some kernel bug.
Log line and 'BUG' macro are added to halt code execution in this case.
Signed-off-by: Evgeny Kuznetsov <EXT-Eugeny.Kuznetsov@nokia.com>
---
arch/arm/plat-omap/gpio.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index c05c653..7669928 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -1318,6 +1318,13 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
if (bank->method == METHOD_GPIO_44XX)
isr_reg = bank->base + OMAP4_GPIO_IRQSTATUS0;
#endif
+
+ if (!isr_reg) {
+ printk(KERN_ERR "FATAL: Incorrect GPIO method %i\n",
+ bank->method);
+ BUG();
+ }
+
while(1) {
u32 isr_saved, level_mask = 0;
u32 enabled;
--
1.6.3.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] omap: Ptr "isr_reg" tracked as NULL was dereferenced
2010-10-05 8:42 ` [PATCH 1/1] " Evgeny Kuznetsov
@ 2010-10-05 9:32 ` Felipe Balbi
2010-10-05 9:55 ` Evgeny Kuznetsov
2010-10-05 15:01 ` Kevin Hilman
0 siblings, 2 replies; 8+ messages in thread
From: Felipe Balbi @ 2010-10-05 9:32 UTC (permalink / raw)
To: Evgeny Kuznetsov
Cc: tony@atomide.com, linux-omap@vger.kernel.org,
linux-kernel@vger.kernel.org, khilman@deeprootsystems.com,
akpm@linux-foundation.org, zmc@lurian.net, a.j.buxton@gmail.com
Hi,
On Tue, Oct 05, 2010 at 03:42:10AM -0500, Evgeny Kuznetsov wrote:
>+ if (!isr_reg) {
>+ printk(KERN_ERR "FATAL: Incorrect GPIO method %i\n",
>+ bank->method);
>+ BUG();
>+ }
this could be simply:
BUG_ON(!isr_reg);
--
balbi
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] omap: Ptr "isr_reg" tracked as NULL was dereferenced
2010-10-05 9:32 ` Felipe Balbi
@ 2010-10-05 9:55 ` Evgeny Kuznetsov
2010-10-05 11:48 ` Felipe Balbi
2010-10-05 15:01 ` Kevin Hilman
1 sibling, 1 reply; 8+ messages in thread
From: Evgeny Kuznetsov @ 2010-10-05 9:55 UTC (permalink / raw)
To: balbi
Cc: tony@atomide.com, linux-omap@vger.kernel.org,
linux-kernel@vger.kernel.org, khilman@deeprootsystems.com,
akpm@linux-foundation.org, zmc@lurian.net, a.j.buxton@gmail.com
Hi,
Yes, but no log in that case.
Regards,
Evgeny
On Tue, 2010-10-05 at 12:32 +0300, ext Felipe Balbi wrote:
> Hi,
>
> On Tue, Oct 05, 2010 at 03:42:10AM -0500, Evgeny Kuznetsov wrote:
> >+ if (!isr_reg) {
> >+ printk(KERN_ERR "FATAL: Incorrect GPIO method %i\n",
> >+ bank->method);
> >+ BUG();
> >+ }
>
> this could be simply:
>
> BUG_ON(!isr_reg);
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] omap: Ptr "isr_reg" tracked as NULL was dereferenced
2010-10-05 9:55 ` Evgeny Kuznetsov
@ 2010-10-05 11:48 ` Felipe Balbi
0 siblings, 0 replies; 8+ messages in thread
From: Felipe Balbi @ 2010-10-05 11:48 UTC (permalink / raw)
To: Evgeny Kuznetsov
Cc: Balbi, Felipe, tony@atomide.com, linux-omap@vger.kernel.org,
linux-kernel@vger.kernel.org, khilman@deeprootsystems.com,
akpm@linux-foundation.org, zmc@lurian.net, a.j.buxton@gmail.com
Hi,
(don't top post)
On Tue, Oct 05, 2010 at 04:55:19AM -0500, Evgeny Kuznetsov wrote:
>Yes, but no log in that case.
what do you call the stack dump BUG() shows ??
--
balbi
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] omap: Ptr "isr_reg" tracked as NULL was dereferenced
2010-10-05 9:32 ` Felipe Balbi
2010-10-05 9:55 ` Evgeny Kuznetsov
@ 2010-10-05 15:01 ` Kevin Hilman
2010-10-06 6:33 ` Evgeny Kuznetsov
1 sibling, 1 reply; 8+ messages in thread
From: Kevin Hilman @ 2010-10-05 15:01 UTC (permalink / raw)
To: balbi
Cc: Evgeny Kuznetsov, tony@atomide.com, linux-omap@vger.kernel.org,
linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
zmc@lurian.net, a.j.buxton@gmail.com
Felipe Balbi <balbi@ti.com> writes:
> Hi,
>
> On Tue, Oct 05, 2010 at 03:42:10AM -0500, Evgeny Kuznetsov wrote:
>>+ if (!isr_reg) {
>>+ printk(KERN_ERR "FATAL: Incorrect GPIO method %i\n",
>>+ bank->method);
>>+ BUG();
>>+ }
>
> this could be simply:
>
> BUG_ON(!isr_reg);
WARN_ON is better.
A BUG() will panic the kernel and stop everything. This is not an error
condition that should prevent the entire kernel from running.
>From asm-generic/bug.h:
/*
* Don't use BUG() or BUG_ON() unless there's really no way out; one
* example might be detecting data structure corruption in the middle
* of an operation that can't be backed out of. If the (sub)system
* can somehow continue operating, perhaps with reduced functionality,
* it's probably not BUG-worthy.
*
* If you're tempted to BUG(), think again: is completely giving up
* really the *only* solution? There are usually better options, where
* users don't need to reboot ASAP and can mostly shut down cleanly.
*/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] omap: Ptr "isr_reg" tracked as NULL was dereferenced
2010-10-05 15:01 ` Kevin Hilman
@ 2010-10-06 6:33 ` Evgeny Kuznetsov
2010-10-08 7:49 ` Evgeny Kuznetsov
0 siblings, 1 reply; 8+ messages in thread
From: Evgeny Kuznetsov @ 2010-10-06 6:33 UTC (permalink / raw)
To: ext Kevin Hilman, balbi
Cc: balbi, tony@atomide.com, linux-omap@vger.kernel.org,
linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
zmc@lurian.net, a.j.buxton@gmail.com
On Tue, 2010-10-05 at 08:01 -0700, ext Kevin Hilman wrote:
> Felipe Balbi <balbi@ti.com> writes:
>
> > Hi,
> >
> > On Tue, Oct 05, 2010 at 03:42:10AM -0500, Evgeny Kuznetsov wrote:
> >>+ if (!isr_reg) {
> >>+ printk(KERN_ERR "FATAL: Incorrect GPIO method %i\n",
> >>+ bank->method);
> >>+ BUG();
> >>+ }
> >
> > this could be simply:
> >
> > BUG_ON(!isr_reg);
>
> WARN_ON is better.
>
> A BUG() will panic the kernel and stop everything. This is not an error
> condition that should prevent the entire kernel from running.
'isr_reg' is dereferenced later in code:
...
isr_saved = isr = __raw_readl(isr_reg) & enabled;
...
So this will stop kernel anyway.
I just hoped to help in understanding of issue by log line. WARN_ON
could be used for this.
As a variant compilation error could be added, to prevent situation when
kernel is incorrectly configured.
E.g.:
#if !defined(CONFIG_ARCH_OMAP1) &&
!defined(CONFIG_ARCH_OMAP15XX) &&
!defined(CONFIG_ARCH_OMAP16XX) &&
!defined(CONFIG_ARCH_OMAP730) &&
!defined(CONFIG_ARCH_OMAP850) &&
!defined(CONFIG_ARCH_OMAP2) &&
!defined(CONFIG_ARCH_OMAP3) &&
!defined(CONFIG_ARCH_OMAP4)
#error "Incorrect arch configuration"
#endif
But there are still cases when 'isr_reg' could have NULL value (if
'bank->method' is not equal to configured one).
Regards,
Evgeny
>
> From asm-generic/bug.h:
>
> /*
> * Don't use BUG() or BUG_ON() unless there's really no way out; one
> * example might be detecting data structure corruption in the middle
> * of an operation that can't be backed out of. If the (sub)system
> * can somehow continue operating, perhaps with reduced functionality,
> * it's probably not BUG-worthy.
> *
> * If you're tempted to BUG(), think again: is completely giving up
> * really the *only* solution? There are usually better options, where
> * users don't need to reboot ASAP and can mostly shut down cleanly.
> */
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] omap: Ptr "isr_reg" tracked as NULL was dereferenced
2010-10-06 6:33 ` Evgeny Kuznetsov
@ 2010-10-08 7:49 ` Evgeny Kuznetsov
0 siblings, 0 replies; 8+ messages in thread
From: Evgeny Kuznetsov @ 2010-10-08 7:49 UTC (permalink / raw)
To: ext Kevin Hilman, balbi
Cc: tony@atomide.com, linux-omap@vger.kernel.org,
linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
zmc@lurian.net, a.j.buxton
On Wed, 2010-10-06 at 10:33 +0400, Evgeny Kuznetsov wrote:
> On Tue, 2010-10-05 at 08:01 -0700, ext Kevin Hilman wrote:
> > Felipe Balbi <balbi@ti.com> writes:
> >
> > > Hi,
> > >
> > > On Tue, Oct 05, 2010 at 03:42:10AM -0500, Evgeny Kuznetsov wrote:
> > >>+ if (!isr_reg) {
> > >>+ printk(KERN_ERR "FATAL: Incorrect GPIO method %i\n",
> > >>+ bank->method);
> > >>+ BUG();
> > >>+ }
> > >
> > > this could be simply:
> > >
> > > BUG_ON(!isr_reg);
> >
> > WARN_ON is better.
> >
> > A BUG() will panic the kernel and stop everything. This is not an error
> > condition that should prevent the entire kernel from running.
>
> 'isr_reg' is dereferenced later in code:
> ...
> isr_saved = isr = __raw_readl(isr_reg) & enabled;
> ...
> So this will stop kernel anyway.
> I just hoped to help in understanding of issue by log line. WARN_ON
> could be used for this.
>
> As a variant compilation error could be added, to prevent situation when
> kernel is incorrectly configured.
> E.g.:
> #if !defined(CONFIG_ARCH_OMAP1) &&
> !defined(CONFIG_ARCH_OMAP15XX) &&
> !defined(CONFIG_ARCH_OMAP16XX) &&
> !defined(CONFIG_ARCH_OMAP730) &&
> !defined(CONFIG_ARCH_OMAP850) &&
> !defined(CONFIG_ARCH_OMAP2) &&
> !defined(CONFIG_ARCH_OMAP3) &&
> !defined(CONFIG_ARCH_OMAP4)
>
> #error "Incorrect arch configuration"
> #endif
>
> But there are still cases when 'isr_reg' could have NULL value (if
> 'bank->method' is not equal to configured one).
>
> Regards,
> Evgeny
If 'isr_reg' is NULL then interrupt could not be handled. We may unmask
the GPIO bank interrupt to continue handle GPIO interrupts for other
lines. And exit handler to prevent kernel oops since 'isr_reg' is
dereferenced later in code(see my message above).
if (WARN_ON(!isr_reg)) {
desc->chip->unmask(irq);
return;
}
One thing I warn about that we could not clear edge sensitive
interrupts:
_enable_gpio_irqbank(bank, isr_saved & ~level_mask, 0);
_clear_gpio_irqbank(bank, isr_saved & ~level_mask);
_enable_gpio_irqbank(bank, isr_saved & ~level_mask, 1);
What do you think?
Evgeny.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-10-08 7:54 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-05 8:42 [PATCH 0/1] omap: Ptr "isr_reg" tracked as NULL was dereferenced Evgeny Kuznetsov
2010-10-05 8:42 ` [PATCH 1/1] " Evgeny Kuznetsov
2010-10-05 9:32 ` Felipe Balbi
2010-10-05 9:55 ` Evgeny Kuznetsov
2010-10-05 11:48 ` Felipe Balbi
2010-10-05 15:01 ` Kevin Hilman
2010-10-06 6:33 ` Evgeny Kuznetsov
2010-10-08 7:49 ` Evgeny Kuznetsov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox