From: David Gibson Date: Sun, 13 Nov 2011 17:18:58 +0000 (+0000) Subject: pseries: Fix buggy spapr_vio_find_by_reg() X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~4997^2~6^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5435352ce6abfb8a7540ae7d47e981d329120cca;p=sdk%2Femulator%2Fqemu.git pseries: Fix buggy spapr_vio_find_by_reg() 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 Signed-off-by: Alexander Graf --- diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c index 25cfc9d..b7b3ddd 100644 --- a/hw/spapr_vio.c +++ b/hw/spapr_vio.c @@ -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