Commit 84b62c72 authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Michael Ellerman

powerpc: Ensure that ppc_md is empty before probing for machine type

Anything in there will be overwritten, so it helps catching nasty
bugs if we check that it's indeed full of NULL's before we do so.
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 7025776e
...@@ -575,6 +575,7 @@ void probe_machine(void) ...@@ -575,6 +575,7 @@ void probe_machine(void)
{ {
extern struct machdep_calls __machine_desc_start; extern struct machdep_calls __machine_desc_start;
extern struct machdep_calls __machine_desc_end; extern struct machdep_calls __machine_desc_end;
unsigned int i;
/* /*
* Iterate all ppc_md structures until we find the proper * Iterate all ppc_md structures until we find the proper
...@@ -582,6 +583,17 @@ void probe_machine(void) ...@@ -582,6 +583,17 @@ void probe_machine(void)
*/ */
DBG("Probing machine type ...\n"); DBG("Probing machine type ...\n");
/*
* Check ppc_md is empty, if not we have a bug, ie, we setup an
* entry before probe_machine() which will be overwritten
*/
for (i = 0; i < (sizeof(ppc_md) / sizeof(void *)); i++) {
if (((void **)&ppc_md)[i]) {
printk(KERN_ERR "Entry %d in ppc_md non empty before"
" machine probe !\n", i);
}
}
for (machine_id = &__machine_desc_start; for (machine_id = &__machine_desc_start;
machine_id < &__machine_desc_end; machine_id < &__machine_desc_end;
machine_id++) { machine_id++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment