mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
dm: core: Don't allow uclass use before ready
At present it is possible to call uclass_get() before driver model is
inited. In fact this happens on x86 boards which use Intel FSPv1, since
mrccache_get_region() tries to get the SPI flash device very early
during init.
This has always been undefined behaviour. Previously it generally worked,
i.e. returned an error code without crashing, because gd->uclass_root_s
is zeroed and the uclass can be added despite driver model not being
ready, due to the way lists are implemented. With the change to use a
gd->uclass_root pointer, this no-longer works. For example, it causes a
hang on minnowmax.
Fix this by adding a check that driver model is ready when uclass_get() is
called. This function is called in the process of locating any device, so
it is a good place to add the check.
This fixes booting on minnowmax.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 8a715530bb
("dm: core: Allow the uclass list to move")
This commit is contained in:
parent
b18b38f2ae
commit
1e9ced28f1
3 changed files with 6 additions and 1 deletions
|
@ -146,6 +146,9 @@ int uclass_get(enum uclass_id id, struct uclass **ucp)
|
|||
{
|
||||
struct uclass *uc;
|
||||
|
||||
/* Immediately fail if driver model is not set up */
|
||||
if (!gd->uclass_root)
|
||||
return -EDEADLK;
|
||||
*ucp = NULL;
|
||||
uc = uclass_find(id);
|
||||
if (!uc) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue