mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miloslav Semler <majkls@prepere.com>
To: Adrian Bunk <bunk@kernel.org>, bunk@stusta.de
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] CHRP: Fix possible NULL pointer dereference
Date: Wed, 03 Sep 2008 11:55:18 +0200	[thread overview]
Message-ID: <48BE5F06.9060406@prepere.com> (raw)

 This fixes a possible NULL pointer dereference inside of strncmp() if
of_get_property() fails.

This is backport of:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9ac71d00398674aaec664f30559f0a21d963862f

Signed-off-by: Miloslav Semler
---
diff -uprN linux-2.6.16.62/arch/powerpc/platforms/chrp/setup.c
linux-2.6.16.62-new/arch/powerpc/platforms/chrp/setup.c
--- linux-2.6.16.62/arch/powerpc/platforms/chrp/setup.c 2008-07-21
21:48:10.000000000 +0200
+++ linux-2.6.16.62-new/arch/powerpc/platforms/chrp/setup.c    
2008-09-03 11:33:54.000000000 +0200
@@ -103,7 +103,7 @@ void chrp_show_cpuinfo(struct seq_file *
        seq_printf(m, "machine\t\t: CHRP %s\n", model);

        /* longtrail (goldengate) stuff */
-       if (!strncmp(model, "IBM,LongTrail", 13)) {
+       if (model && !strncmp(model, "IBM,LongTrail", 13)) {
                /* VLSI VAS96011/12 `Golden Gate 2' */
                /* Memory banks */
                sdramen = (in_le32(gg2_pci_config_base + GG2_PCI_DRAM_CTRL)
@@ -190,9 +190,14 @@ static void __init sio_fixup_irq(const c
 static void __init sio_init(void)
 {
        struct device_node *root;
+       const char *model;

-       if ((root = find_path_device("/")) &&
-           !strncmp(get_property(root, "model", NULL), "IBM,LongTrail",
13)) {
+       root = find_path_device("/");
+       if(!root)
+               return;
+
+       model = get_property(root, "model", NULL);
+       if(model && !strncmp(model, "IBM,LongTrail", 13)) {
                /* logical device 0 (KBC/Keyboard) */
                sio_fixup_irq("keyboard", 0, 1, 2);
                /* select logical device 1 (KBC/Mouse) */




                 reply	other threads:[~2008-09-03 10:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=48BE5F06.9060406@prepere.com \
    --to=majkls@prepere.com \
    --cc=bunk@kernel.org \
    --cc=bunk@stusta.de \
    --cc=linux-kernel@vger.kernel.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

Powered by JetHome