From: Evgeny Kuznetsov <EXT-Eugeny.Kuznetsov@nokia.com>
To: ext Kevin Hilman <khilman@deeprootsystems.com>, balbi@ti.com
Cc: balbi@ti.com, "tony@atomide.com" <tony@atomide.com>,
"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"zmc@lurian.net" <zmc@lurian.net>,
"a.j.buxton@gmail.com" <a.j.buxton@gmail.com>
Subject: Re: [PATCH 1/1] omap: Ptr "isr_reg" tracked as NULL was dereferenced
Date: Wed, 06 Oct 2010 10:33:22 +0400 [thread overview]
Message-ID: <1286346802.24366.89.camel@ekuznets-lx-nokia> (raw)
In-Reply-To: <877hhwvg3r.fsf@deeprootsystems.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.
> */
next prev parent reply other threads:[~2010-10-06 6:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-05 8:42 [PATCH 0/1] " 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 [this message]
2010-10-08 7:49 ` Evgeny Kuznetsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1286346802.24366.89.camel@ekuznets-lx-nokia \
--to=ext-eugeny.kuznetsov@nokia.com \
--cc=a.j.buxton@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=balbi@ti.com \
--cc=khilman@deeprootsystems.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.com \
--cc=zmc@lurian.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®