Skip to content
Snippets Groups Projects
Commit 2fda14ae authored by Simon Glass's avatar Simon Glass
Browse files

dm: core: Check for empty list in uclass_find_device()


This function needs to check the list has entries before traversing it.
Fix this bug.

Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
parent 3834f417
No related branches found
No related tags found
No related merge requests found
......@@ -153,6 +153,8 @@ int uclass_find_device(enum uclass_id id, int index, struct udevice **devp)
ret = uclass_get(id, &uc);
if (ret)
return ret;
if (list_empty(&uc->dev_head))
return -ENODEV;
list_for_each_entry(dev, &uc->dev_head, uclass_node) {
if (!index--) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment