All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] CHRP: Fix possible NULL pointer dereference
@ 2008-09-03  9:55 Miloslav Semler
  0 siblings, 0 replies; only message in thread
From: Miloslav Semler @ 2008-09-03  9:55 UTC (permalink / raw)
  To: Adrian Bunk, bunk; +Cc: linux-kernel

 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) */




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-03 10:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-03  9:55 [PATCH] CHRP: Fix possible NULL pointer dereference Miloslav Semler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.