linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: Cyrill Gorcunov <gorcunov@gmail.com>
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 20:48:53 +1100	[thread overview]
Message-ID: <1196243333.2109.2.camel@concordia> (raw)
In-Reply-To: <aa79d98a0711252346m583b652bocf72e11077da352e@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1828 bytes --]

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;
       }


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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2007-11-28  9:48 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 [this message]
2007-11-28 10:53   ` Cyrill Gorcunov
2007-11-28 10:59     ` Cyrill Gorcunov
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=1196243333.2109.2.camel@concordia \
    --to=michael@ellerman.id.au \
    --cc=gorcunov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --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).