dm: Avoid accessing uclasses before they are ready

Don't allow access to uclasses before they have been initialised.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index a27f3d5..61ca17e 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -23,6 +23,8 @@
 {
 	struct uclass *uc;
 
+	if (!gd->dm_root)
+		return NULL;
 	/*
 	 * TODO(sjg@chromium.org): Optimise this, perhaps moving the found
 	 * node to the start of the list, or creating a linear array mapping