aboutsummaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-07-07 13:12:10 -0600
committerBin Meng <bmeng.cn@gmail.com>2020-07-17 14:32:24 +0800
commit20349781a3ca833c67126888ddfce7c1517c772e (patch)
treeeb84642875edd981bf865836d8f69ca61e4ede42 /include/dm
parent58a6ccd34e79acb7835699eab9c1ecb6cc8bbd47 (diff)
downloadu-boot-20349781a3ca833c67126888ddfce7c1517c772e.zip
u-boot-20349781a3ca833c67126888ddfce7c1517c772e.tar.gz
u-boot-20349781a3ca833c67126888ddfce7c1517c772e.tar.bz2
pci: Avoid a crash in device_is_on_pci_bus()
This function cannot currently be called on the root node. Add a check for this as well as a test. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/device.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/dm/device.h b/include/dm/device.h
index f5738a0..953706c 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -764,7 +764,7 @@ int dev_enable_by_path(const char *path);
*/
static inline bool device_is_on_pci_bus(const struct udevice *dev)
{
- return device_get_uclass_id(dev->parent) == UCLASS_PCI;
+ return dev->parent && device_get_uclass_id(dev->parent) == UCLASS_PCI;
}
/**