Patchwork Fix infinite loop in pnp_get_ioresource()

login
register
about
Submitter Stefan Reinauer
Date 2011-01-28 23:03:32
Message ID <AANLkTim-0VV7wj+DvX0WEt45Orv25Pa8nLX86Hd32m11@mail.gmail.com>
Download mbox | patch
Permalink /patch/2578/
State Accepted
Commit r6323
Headers show

Comments

Stefan Reinauer - 2011-01-28 23:03:32
Hi Alexandru,

thanks for finding this issue. I think I ran into this before. We
should not silently continue in this case, and not create a resource
either. The problem is most likely caused by a faulty devicetree.cb or
superio driver. Hence, I suggest to print an error instead. See patch.
Can you test, please? It should tell you which device / index is
causing the problem.

Stefan

On Fri, Jan 28, 2011 at 2:14 AM, Alex G. <mr.nuke.me@gmail.com> wrote:
> Fix an infinite loop in pnp_get_ioresource(), which freezes coreboot if
> a rare condition arises.
>
> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
> ---
>
>
> --
> coreboot mailing list: coreboot@coreboot.org
> http://www.coreboot.org/mailman/listinfo/coreboot
>
Alexandru Gagniuc - 2011-01-29 00:54:41
Hi Stefan,

Thanks for the heads-up. In my case it's the MIDI device from the
W83627EHG that has the broken mask. I see no difference when not
creating the resource, so I doubt this breaks anything.

Alex

Acked-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>

On 01/29/2011 01:03 AM, Stefan Reinauer wrote:
> Hi Alexandru,
> 
> thanks for finding this issue. I think I ran into this before. We
> should not silently continue in this case, and not create a resource
> either. The problem is most likely caused by a faulty devicetree.cb or
> superio driver. Hence, I suggest to print an error instead. See patch.
> Can you test, please? It should tell you which device / index is
> causing the problem.
> 
> Stefan
> 
> On Fri, Jan 28, 2011 at 2:14 AM, Alex G. <mr.nuke.me@gmail.com> wrote:
>> Fix an infinite loop in pnp_get_ioresource(), which freezes coreboot if
>> a rare condition arises.
>>
>> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
>> ---
>>
>>
>> --
>> coreboot mailing list: coreboot@coreboot.org
>> http://www.coreboot.org/mailman/listinfo/coreboot
>>
> 
> 
>

Patch

Fix an infinite loop in pnp_get_ioresource(), which freezes coreboot if
a rare condition arises.

Based on findings by Alexandru Gagniuc <mr.nuke.me@gmail.com>

Signed-off-by: Stefan Reinauer <reinauer@google.com>

diff --git a/src/devices/pnp_device.c b/src/devices/pnp_device.c
index b2bca03..4a6d266 100644
--- a/src/devices/pnp_device.c
+++ b/src/devices/pnp_device.c
@@ -170,6 +170,12 @@  static void pnp_get_ioresource(device_t dev, u8 index, struct io_info *info)
 	struct resource *resource;
 	unsigned moving, gran, step;
 
+	if (!info->mask) {
+		printk(BIOS_ERR, "ERROR: device %s index %d has no mask.\n",
+				dev_path(dev), index);
+		return;
+	}
+
 	resource = new_resource(dev, index);
 
 	/* Initilize the resource. */