]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: avoid NULL dereference in lists_bind_fdt()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Mon, 11 Jul 2022 06:21:31 +0000 (08:21 +0200)
committerSimon Glass <sjg@chromium.org>
Tue, 26 Jul 2022 08:30:56 +0000 (02:30 -0600)
If parameter drv of lists_bind_fdt() is specified, we want to bind to this
specific driver even if its field of_match is NULL.

If entry->of_match is NULL, we should not dereference it in a debug
statement.

Fixes: d3e773613b6d ("dm: core: Use U-Boot logging instead of pr_debug()")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/core/lists.c

index 22ccd9faaa91224e55e54424c7d86b722da55236..93514a744d9d171e81769663e3edf07531779221 100644 (file)
@@ -241,9 +241,10 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
                        }
                }
 
-               log_debug("   - found match at '%s': '%s' matches '%s'\n",
-                         entry->name, entry->of_match->compatible,
-                         id->compatible);
+               if (entry->of_match)
+                       log_debug("   - found match at '%s': '%s' matches '%s'\n",
+                                 entry->name, entry->of_match->compatible,
+                                 id->compatible);
                ret = device_bind_with_driver_data(parent, entry, name,
                                                   id->data, node, &dev);
                if (ret == -ENODEV) {