mpc832x_rdb.c: prevent using uninitialized variable
Subsystems (2)
PATCH 1/1 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.
--- arch/powerpc/platforms/83xx/mpc832x_rdb.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/83xx/mpc832x_rdb.c +2 -2
@@ -79,14 +79,14 @@ device_initcall(mpc83xx_spi_devices_init);static void __init mpc832x_rdb_setup_arch (void ) {#if defined(CONFIG_PCI ) || defined(CONFIG_QUICC_ENGINE ) -struct device_node *np; +struct device_node *np =NULL ;#endif if (ppc_md.progress) ppc_md.progress ("mpc832x_rdb_setup_arch()" ,0 );#ifdef CONFIG_PCI -for (np =NULL ; (np =of_find_node_by_type (np,"pci" )) !=NULL ;) +for (; (np =of_find_node_by_type (np,"pci" )) !=NULL ;)mpc83xx_add_bridge (np); ppc_md.pci_exclude_device = mpc83xx_exclude_device;
Signature · 1 line
1.5.0.6
Quoted 2 lines · Anton Vorontsov
If
CONFIG_PCIundefined, np will be used uninitialized, therebyfind_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.
-Scott
Quoted 7 lines · Scott Wood
Quoted 2 lines · Anton Vorontsov
If
CONFIG_PCIundefined, np will be used uninitialized, therebyfind_node_by_name(np, "par_io")will fail.This is the wrong fix -- you should be passing NULL to the
par_iocall rather than np. Otherwise, if thepar_iois 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 <[email protected]>
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.
--- arch/powerpc/platforms/83xx/mpc832x_rdb.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/platforms/83xx/mpc832x_rdb.c +1 -1
@@ -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);
Signature · 1 line
1.5.0.6