2005-01-14 19:49:32

by Rik van Riel

[permalink] [raw]
Subject: [PATCH] fix xenU kernel crash in dmi_iterate

Hi Andrew,

In unprivileged Xen domains, all that __ioremap() does is a
"return NULL", which causes dmi_iterate() to crash the kernel
at boot time.

This trivial check bails dmi_iterate() out of the loop when
it finds that the ioremap() returned a NULL pointer.

Signed-off-by: Rik van Riel <[email protected]>

--- linux/arch/i386/kernel/dmi_scan.c.orig 2005-01-12 14:55:14.000000000 -0500
+++ linux/arch/i386/kernel/dmi_scan.c 2005-01-12 16:06:27.000000000 -0500
@@ -105,6 +105,8 @@
char __iomem *p, *q;

for (p = q = ioremap(0xF0000, 0x10000); q < p + 0x10000; q += 16) {
+ if (p == NULL)
+ return -1;
memcpy_fromio(buf, q, 15);
if(memcmp(buf, "_DMI_", 5)==0 && dmi_checksum(buf))
{


2005-01-14 22:05:18

by Ulrich Drepper

[permalink] [raw]
Subject: Re: [PATCH] fix xenU kernel crash in dmi_iterate

On Fri, 14 Jan 2005 14:49:10 -0500 (EST), Rik van Riel <[email protected]> wrote:
> char __iomem *p, *q;
>
> for (p = q = ioremap(0xF0000, 0x10000); q < p + 0x10000; q += 16) {
> + if (p == NULL)
> + return -1;
> memcpy_fromio(buf, q, 15);
> if(memcmp(buf, "_DMI_", 5)==0 && dmi_checksum(buf))
> {

SInce p is not modified in the loop, this certainly should look like this

p = ioremap(0xF0000, 0x10000);
if (p == NULL)
return -1;
for (q = p; q < p + 0x10000; q += 16) {
memcpy_fromio(buf, q, 15);
...