* [PATCH] mpc832x_rdb.c: prevent using uninitialized variable
@ 2007-07-26 14:01 Anton Vorontsov
2007-07-26 16:48 ` Scott Wood
0 siblings, 1 reply; 3+ messages in thread
From: Anton Vorontsov @ 2007-07-26 14:01 UTC (permalink / raw)
To: linuxppc-dev
If CONFIG_PCI undefined, np will be used uninitialized, thereby
find_node_by_name(np, "par_io") will fail.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
arch/powerpc/platforms/83xx/mpc832x_rdb.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/83xx/mpc832x_rdb.c b/arch/powerpc/platforms/83xx/mpc832x_rdb.c
index c5463c7..b16dce2 100644
--- a/arch/powerpc/platforms/83xx/mpc832x_rdb.c
+++ b/arch/powerpc/platforms/83xx/mpc832x_rdb.c
@@ -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;
--
1.5.0.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mpc832x_rdb.c: prevent using uninitialized variable
2007-07-26 14:01 [PATCH] mpc832x_rdb.c: prevent using uninitialized variable Anton Vorontsov
@ 2007-07-26 16:48 ` Scott Wood
2007-07-27 10:23 ` Anton Vorontsov
0 siblings, 1 reply; 3+ messages in thread
From: Scott Wood @ 2007-07-26 16:48 UTC (permalink / raw)
To: Anton Vorontsov; +Cc: linuxppc-dev
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.
-Scott
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mpc832x_rdb.c: prevent using uninitialized variable
2007-07-26 16:48 ` Scott Wood
@ 2007-07-27 10:23 ` Anton Vorontsov
0 siblings, 0 replies; 3+ messages in thread
From: Anton Vorontsov @ 2007-07-27 10:23 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev
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@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@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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-27 10:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-26 14:01 [PATCH] mpc832x_rdb.c: prevent using uninitialized variable Anton Vorontsov
2007-07-26 16:48 ` Scott Wood
2007-07-27 10:23 ` Anton Vorontsov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).