diff options
author | Simon Glass <sjg@chromium.org> | 2015-07-31 09:31:19 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-08-05 08:42:40 -0600 |
commit | 2fda14ae6aa36798b59ab0591a2009ead206159b (patch) | |
tree | d179bd7e426095ec4377cc10ed682aca8fec8c9d /drivers | |
parent | 3834f41720b9340c97d8970d5a712fdcf2031df3 (diff) | |
download | u-boot-imx-2fda14ae6aa36798b59ab0591a2009ead206159b.zip u-boot-imx-2fda14ae6aa36798b59ab0591a2009ead206159b.tar.gz u-boot-imx-2fda14ae6aa36798b59ab0591a2009ead206159b.tar.bz2 |
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')
-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--) { |