[<prev] [next>] [day] [month] [year] [list]
Message-ID: <48BE5F06.9060406@prepere.com>
Date: Wed, 03 Sep 2008 11:55:18 +0200
From: Miloslav Semler <majkls@...pere.com>
To: Adrian Bunk <bunk@...nel.org>, bunk@...sta.de
CC: linux-kernel@...r.kernel.org
Subject: [PATCH] CHRP: Fix possible NULL pointer dereference
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) */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists