From: Simon Glass Date: Sun, 9 Oct 2022 03:33:20 +0000 (-0600) Subject: dm: core: Fix lists_bind_fdt() using non-existent of_match X-Git-Tag: v2023.07~279^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d13879211285d5cc5cfb727eb36b41da0111edf0;p=platform%2Fkernel%2Fu-boot.git dm: core: Fix lists_bind_fdt() using non-existent of_match The call to device_bind_with_driver_data() passes id->data but if the entry has no of_match then the id has not been set by the selected driver. Normally this passes unnoticed since a previous driver likely had an of_match value, so the id is set to that. Of course it is not correct to pass the id->data from a different driver. With clang-14 the driver ordering is such that the id is never actually set in the 'bind /usb@1 usb_ether' line in test_bind_unbind_with_node() thus causing a crash. Fix this by passing 0 if the of_match for a driver does not exist. Signed-off-by: Simon Glass --- diff --git a/drivers/core/lists.c b/drivers/core/lists.c index c49695b..3878957 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -222,6 +222,7 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp, log_debug(" - attempt to match compatible string '%s'\n", compat); + id = NULL; for (entry = driver; entry != driver + n_ents; entry++) { if (drv) { if (drv != entry) @@ -250,7 +251,8 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp, entry->name, entry->of_match->compatible, id->compatible); ret = device_bind_with_driver_data(parent, entry, name, - id->data, node, &dev); + id ? id->data : 0, node, + &dev); if (ret == -ENODEV) { log_debug("Driver '%s' refuses to bind\n", entry->name); continue;