Patchwork Fix infinite loop in pnp_get_ioresource()

login
register
about
Submitter Alexandru Gagniuc
Date 2011-01-28 10:14:12
Message ID <4D4296F4.2050804@gmail.com>
Download mbox | patch
Permalink /patch/2573/
State Superseded
Headers show

Comments

Alexandru Gagniuc - 2011-01-28 10:14:12
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>
---

Patch

Index: src/devices/pnp_device.c
===================================================================
--- src/devices/pnp_device.c	(revision 6315)
+++ src/devices/pnp_device.c	(working copy)
@@ -183,6 +183,12 @@ 
 	step = 1 << gran;
 
 	/* Find the first bit that moves. */
+	/* If by any chance, 'moving' will be zero when entering the loop
+	 * we will never exit it. We need to make sure that execution
+	 * continues if/when this conditon arises.
+	 * FIXME: Is this the best solution?
+	 */
+	if(moving != 0)
 	while ((moving & step) == 0) {
 		gran--;
 		step >>= 1;