diff options
author | Simon Glass <sjg@chromium.org> | 2015-07-31 15:31:19 (GMT) |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-08-05 14:42:40 (GMT) |
commit | 2fda14ae6aa36798b59ab0591a2009ead206159b (patch) | |
tree | d179bd7e426095ec4377cc10ed682aca8fec8c9d /drivers/core/uclass.c | |
parent | 3834f41720b9340c97d8970d5a712fdcf2031df3 (diff) | |
download | u-boot-fsl-qoriq-2fda14ae6aa36798b59ab0591a2009ead206159b.tar.xz |
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: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/core/uclass.c')
-rw-r--r-- | drivers/core/uclass.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index aba9880..ffe6995 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -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--) { |