Skip to contentSkip to conversation

hw/arm/sysbus-fdt: fix assert in match function

PATCH In review Peng Hao 2 participants 3 messages Nov 17, 2018 – Nov 19, 2018

lore
Share & tools
lore

Peng Hao

author
#0 lore raw

PATCH 1/1 hw/arm/sysbus-fdt: fix assert in match function

In match function it should not call OBJECK_CHECK. When there is a mismatch, we should continue to match rather than assert().

---
 hw/arm/sysbus-fdt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
hw/arm/sysbus-fdt.c +6 -1
index 0e24c80..41b962d 100644
@@ -419,10 +419,15 @@ static int add_amd_xgbe_fdt_node(SysBusDevice *sbdev, void *opaque)
 static bool vfio_platform_match(SysBusDevice *sbdev,
                                 const BindingEntry *entry)
 {
-    VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(sbdev);
+    VFIOPlatformDevice *vdev;
     const char *compat;
     unsigned int n;
 
+    vdev = (VFIOPlatformDevice *) object_dynamic_cast(OBJECT(sbdev),
+                                                TYPE_VFIO_PLATFORM);
+    if (!vdev)
+        return false;
+
     for (n = vdev->num_compat, compat = vdev->compat; n > 0;
          n--, compat += strlen(compat) + 1) {
         if (!strcmp(entry->compat, compat)) {
Signature · 1 line
1.8.3.1
#1 lore raw

Hi Peng,

Quoted 2 lines · Peng Hao

In match function it should not call OBJECK_CHECK. When there is a mismatch, we should continue to match rather than assert().

Normally this issue should have been fixed by
e9ac8e84f0 "hw/arm/sysbus-fdt: Only call match_fn callback if the type matches". Please can you confirm?

Thanks

Eric

Quoted 28 lines
---
 hw/arm/sysbus-fdt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
hw/arm/sysbus-fdt.c +6 -1
index 0e24c80..41b962d 100644
@@ -419,10 +419,15 @@ static int add_amd_xgbe_fdt_node(SysBusDevice *sbdev, void *opaque)
 static bool vfio_platform_match(SysBusDevice *sbdev,
                                 const BindingEntry *entry)
 {
-    VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(sbdev);
+    VFIOPlatformDevice *vdev;
     const char *compat;
     unsigned int n;
 
+    vdev = (VFIOPlatformDevice *) object_dynamic_cast(OBJECT(sbdev),
+                                                TYPE_VFIO_PLATFORM);
+    if (!vdev)
+        return false;
+
     for (n = vdev->num_compat, compat = vdev->compat; n > 0;
          n--, compat += strlen(compat) + 1) {
         if (!strcmp(entry->compat, compat)) {
#2 lore raw

Re: [Qemu-arm] [Qemu-devel] [PATCH] hw/arm/sysbus-fdt: fix assert in matchfunction

Quoted 10 lines

Hi Peng,

Quoted 2 lines · Peng Hao

In match function it should not call OBJECK_CHECK. When there is a mismatch, we should continue to match rather than assert().

Normally this issue should have been fixed by
e9ac8e84f0 "hw/arm/sysbus-fdt: Only call match_fn callback if the type matches". Please can you confirm?

yes,it works after updating your patch.
Thanks.

Quoted 31 lines

Thanks

Eric

Quoted 28 lines
---
 hw/arm/sysbus-fdt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
hw/arm/sysbus-fdt.c +6 -1
index 0e24c80..41b962d 100644
@@ -419,10 +419,15 @@ static int add_amd_xgbe_fdt_node(SysBusDevice *sbdev, void *opaque)
 static bool vfio_platform_match(SysBusDevice *sbdev,
                                 const BindingEntry *entry)
 {
-    VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(sbdev);
+    VFIOPlatformDevice *vdev;
     const char *compat;
     unsigned int n;
 
+    vdev = (VFIOPlatformDevice *) object_dynamic_cast(OBJECT(sbdev),
+                                                TYPE_VFIO_PLATFORM);
+    if (!vdev)
+        return false;
+
     for (n = vdev->num_compat, compat = vdev->compat; n > 0;
          n--, compat += strlen(compat) + 1) {
         if (!strcmp(entry->compat, compat)) {