[PATCH] mpc832x_rdb.c: prevent using uninitialized variable

Anton Vorontsov avorontsov at ru.mvista.com
Fri Jul 27 20:23:49 EST 2007


On Thu, Jul 26, 2007 at 11:48:33AM -0500, Scott Wood wrote:
> On Thu, Jul 26, 2007 at 06:01:39PM +0400, Anton Vorontsov wrote:
> > If CONFIG_PCI undefined, np will be used uninitialized, thereby
> > find_node_by_name(np, "par_io") will fail.
> 
> This is the wrong fix -- you should be passing NULL to the par_io call
> rather than np.  Otherwise, if the par_io is earlier in the tree than the
> pci, you won't find it.

Oops. Right you are, thanks!

I hope this is proper fix.

- - - -
From: Anton Vorontsov <avorontsov at ru.mvista.com>
Subject: [POWERPC] mpc832x_rdb.c: prevent using uninitialized variable

If CONFIG_PCI undefined, np will be used uninitialized, thereby
find_node_by_name(np, "par_io") will fail.

of_find_node_by_name(np, "par_io") isn't used inside loop,
thus we can safely pass NULL instead of np.

Signed-off-by: Anton Vorontsov <avorontsov at ru.mvista.com>
---
 arch/powerpc/platforms/83xx/mpc832x_rdb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/platforms/83xx/mpc832x_rdb.c b/arch/powerpc/platforms/83xx/mpc832x_rdb.c
index b2b28a4..93ba957 100644
--- a/arch/powerpc/platforms/83xx/mpc832x_rdb.c
+++ b/arch/powerpc/platforms/83xx/mpc832x_rdb.c
@@ -56,7 +56,7 @@ static void __init mpc832x_rdb_setup_arch(void)
 #ifdef CONFIG_QUICC_ENGINE
 	qe_reset();
 
-	if ((np = of_find_node_by_name(np, "par_io")) != NULL) {
+	if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {
 		par_io_init(np);
 		of_node_put(np);
 
-- 
1.5.0.6




More information about the Linuxppc-dev mailing list