]> Git Repo - qemu.git/commitdiff
pseries: Fix buggy spapr_vio_find_by_reg()
authorDavid Gibson <[email protected]>
Sun, 13 Nov 2011 17:18:58 +0000 (17:18 +0000)
committerAlexander Graf <[email protected]>
Fri, 18 Nov 2011 13:22:45 +0000 (14:22 +0100)
The spapr_vio_find_by_reg() function in hw/spapr_vio.c is supposed to find
the device structure for a PAPR virtual IO device with the given reg value,
and return NULL if none exists.

It does the first ok, but if no device with that reg exists, it just
returns the last device traversed in the list.  This patch fixes it.

Signed-off-by: David Gibson <[email protected]>
Signed-off-by: Alexander Graf <[email protected]>
hw/spapr_vio.c

index 25cfc9d912691e4feee06b41975bd556aa6d073d..b7b3ddd116d67dd99fb9f3f4404afb8e2ae2a9db 100644 (file)
@@ -66,11 +66,11 @@ VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg)
     QTAILQ_FOREACH(qdev, &bus->bus.children, sibling) {
         dev = (VIOsPAPRDevice *)qdev;
         if (dev->reg == reg) {
-            break;
+            return dev;
         }
     }
 
-    return dev;
+    return NULL;
 }
 
 #ifdef CONFIG_FDT
This page took 0.02895 seconds and 4 git commands to generate.