diff mbox series

[v3,kvmtool,2/4] arm/fdt.c: Don't generate the node if generator function is NULL

Message ID 20210713170631.155595-3-alexandru.elisei@arm.com (mailing list archive)
State New, archived
Headers show
Series arm/arm64: PCI Express 1.1 support | expand

Commit Message

Alexandru Elisei July 13, 2021, 5:06 p.m. UTC
Print a more helpful debugging message when a MMIO device hasn't set a
function to generate an FDT node instead of causing a segmentation fault by
dereferencing a NULL pointer.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 arm/fdt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arm/fdt.c b/arm/fdt.c
index 02091e9e0bee..7032985e99a3 100644
--- a/arm/fdt.c
+++ b/arm/fdt.c
@@ -171,7 +171,12 @@  static int setup_fdt(struct kvm *kvm)
 	dev_hdr = device__first_dev(DEVICE_BUS_MMIO);
 	while (dev_hdr) {
 		generate_mmio_fdt_nodes = dev_hdr->data;
-		generate_mmio_fdt_nodes(fdt, dev_hdr, generate_irq_prop);
+		if (generate_mmio_fdt_nodes) {
+			generate_mmio_fdt_nodes(fdt, dev_hdr, generate_irq_prop);
+		} else {
+			pr_debug("Missing FDT node generator for MMIO device %d",
+				 dev_hdr->dev_num);
+		}
 		dev_hdr = device__next_dev(dev_hdr);
 	}