api: storage: Avoid enumeration for non-configured subsystem
If a subsystem wasn't configured, avoid enumeration.
Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
diff --git a/api/api_storage.c b/api/api_storage.c
index d425a9a..b5aaba1 100644
--- a/api/api_storage.c
+++ b/api/api_storage.c
@@ -41,7 +41,7 @@
char *name;
};
-static struct stor_spec specs[ENUM_MAX] = { { 0, 0, 0, 0, "" }, };
+static struct stor_spec specs[ENUM_MAX] = { { 0, 0, 0, 0, NULL }, };
void dev_stor_init(void)
@@ -105,6 +105,10 @@
struct blk_desc *dd;
+ /* Wasn't configured for this type, return 0 directly */
+ if (specs[type].name == NULL)
+ return 0;
+
if (first) {
di->cookie = (void *)blk_get_dev(specs[type].name, 0);
if (di->cookie == NULL)