bootconfig: Add more parse error messages
Add more error messages for following cases. - Exceeding max number of nodes - Config tree data is empty (e.g. comment only) - Config data is empty or exceeding max size - bootconfig is already initialized Link: http://lkml.kernel.org/r/158091060401.27924.9024818742827122764.stgit@devnote2 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
e241d14a82
commit
597c0e3b45
|
@ -373,7 +373,8 @@ static struct xbc_node * __init xbc_add_sibling(char *data, u32 flag)
|
||||||
sib->next = xbc_node_index(node);
|
sib->next = xbc_node_index(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
xbc_parse_error("Too many nodes", data);
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
@ -657,8 +658,10 @@ static int __init xbc_verify_tree(void)
|
||||||
struct xbc_node *n, *m;
|
struct xbc_node *n, *m;
|
||||||
|
|
||||||
/* Empty tree */
|
/* Empty tree */
|
||||||
if (xbc_node_num == 0)
|
if (xbc_node_num == 0) {
|
||||||
|
xbc_parse_error("Empty config", xbc_data);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < xbc_node_num; i++) {
|
for (i = 0; i < xbc_node_num; i++) {
|
||||||
if (xbc_nodes[i].next > xbc_node_num) {
|
if (xbc_nodes[i].next > xbc_node_num) {
|
||||||
|
@ -732,12 +735,17 @@ int __init xbc_init(char *buf)
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
int ret, c;
|
int ret, c;
|
||||||
|
|
||||||
if (xbc_data)
|
if (xbc_data) {
|
||||||
|
pr_err("Error: bootconfig is already initialized.\n");
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
ret = strlen(buf);
|
ret = strlen(buf);
|
||||||
if (ret > XBC_DATA_MAX - 1 || ret == 0)
|
if (ret > XBC_DATA_MAX - 1 || ret == 0) {
|
||||||
|
pr_err("Error: Config data is %s.\n",
|
||||||
|
ret ? "too big" : "empty");
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
|
}
|
||||||
|
|
||||||
xbc_data = buf;
|
xbc_data = buf;
|
||||||
xbc_data_size = ret + 1;
|
xbc_data_size = ret + 1;
|
||||||
|
|
Loading…
Reference in New Issue