Skip to content

Commit

Permalink
api: storage: Avoid enumeration for non-configured subsystem
Browse files Browse the repository at this point in the history
If a subsystem wasn't configured, avoid enumeration.

Signed-off-by: Emmanuel Vadot <[email protected]>
  • Loading branch information
evadot authored and trini committed Oct 24, 2016
1 parent 0dbc9b5 commit 5d81c6d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/api_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct stor_spec {
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)
Expand Down Expand Up @@ -105,6 +105,10 @@ static int dev_stor_get(int type, int first, int *more, struct device_info *di)

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)
Expand Down

0 comments on commit 5d81c6d

Please sign in to comment.