From: "Cyrill Gorcunov" <gorcunov@gmail.com>
To: michael@ellerman.id.au
Cc: Olof Johansson <olof@lixom.net>, PPCML <linuxppc-dev@ozlabs.org>,
Paul Mackerras <paulus@samba.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] PPC: CELLEB - fix potential NULL pointer dereference
Date: Wed, 28 Nov 2007 13:59:16 +0300 [thread overview]
Message-ID: <aa79d98a0711280259o6cc6fb12mf020c4a986d84ca6@mail.gmail.com> (raw)
In-Reply-To: <aa79d98a0711280253x3d1d28d6qa0cee0b731e807fe@mail.gmail.com>
On 11/28/07, Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> On 11/28/07, Michael Ellerman <michael@ellerman.id.au> wrote:
> > On Mon, 2007-11-26 at 10:46 +0300, Cyrill Gorcunov wrote:
> > > This patch adds checking for NULL value returned to prevent possible
> > > NULL pointer dereference.
> > > Also two unneeded 'return' are removed.
> > >
> > > Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> > > ---
> > > Any comments are welcome.
> >
> > I guess it's good to be paranoid, but this is a little verbose:
> >
> > wi0 = of_get_property(node, "device-id", NULL);
> > + if (unlikely((!wi0))) {
> > + printk(KERN_ERR "PCI: device-id not found.\n");
> > + goto error;
> > + }
> > wi1 = of_get_property(node, "vendor-id", NULL);
> > + if (unlikely((!wi1))) {
> > + printk(KERN_ERR "PCI: vendor-id not found.\n");
> > + goto error;
> > + }
> > wi2 = of_get_property(node, "class-code", NULL);
> > + if (unlikely((!wi2))) {
> > + printk(KERN_ERR "PCI: class-code not found.\n");
> > + goto error;
> > + }
> > wi3 = of_get_property(node, "revision-id", NULL);
> > + if (unlikely((!wi3))) {
> > + printk(KERN_ERR "PCI: revision-id not found.\n");
> > + goto error;
> > + }
> >
> > Perhaps instead:
> >
> > wi0 = of_get_property(node, "device-id", NULL);
> > wi1 = of_get_property(node, "vendor-id", NULL);
> > wi2 = of_get_property(node, "class-code", NULL);
> > wi3 = of_get_property(node, "revision-id", NULL);
> >
> > if (!wi0 || !wi1 || !wi2 || !wi3) {
> > printk(KERN_ERR "PCI: Missing device tree properties.\n");
> > goto error;
> > }
>
> Hi Michael, yes that is much better (actually I was doubt about what form of
> which the checking style to use - your form is much compact but mine does
> show where *exactly* the problem appeared). So 'case that is the fake driver
> your form is preferred ;) Ishizaki, could you use Michael's part then?
>
> >
> >
> > cheers
> >
> > --
> > Michael Ellerman
> > OzLabs, IBM Australia Development Lab
> >
> > wwweb: http://michael.ellerman.id.au
> > phone: +61 2 6212 1183 (tie line 70 21183)
> >
> > We do not inherit the earth from our ancestors,
> > we borrow it from our children. - S.M.A.R.T Person
> >
> >
>
> Cyrill
>
Ishizaki I can update the patch if you needed. Should I?
Cyrill
next prev parent reply other threads:[~2007-11-28 10:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-26 7:46 [PATCH] PPC: CELLEB - fix potential NULL pointer dereference Cyrill Gorcunov
2007-11-28 8:52 ` Ishizaki Kou
2007-11-28 9:48 ` Michael Ellerman
2007-11-28 10:53 ` Cyrill Gorcunov
2007-11-28 10:59 ` Cyrill Gorcunov [this message]
2007-11-29 3:22 ` Ishizaki Kou
2007-11-29 5:41 ` Cyrill Gorcunov
2007-11-29 7:44 ` [PATCH] PPC: CELLEB - fix possible " Ishizaki Kou
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=aa79d98a0711280259o6cc6fb12mf020c4a986d84ca6@mail.gmail.com \
--to=gorcunov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=michael@ellerman.id.au \
--cc=olof@lixom.net \
--cc=paulus@samba.org \
/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;
as well as URLs for NNTP newsgroup(s).