From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Subject: [for-next][PATCH 3/5] bootconfig: Add more parse error messages
Date: Wed, 05 Feb 2020 17:21:13 -0500 [thread overview]
Message-ID: <20200205222143.086800401@goodmis.org> (raw)
In-Reply-To: 20200205222110.912457436@goodmis.org
From: Masami Hiramatsu <mhiramat@kernel.org>
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>
---
lib/bootconfig.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index 055014e233a5..a98ae136529c 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -373,7 +373,8 @@ static struct xbc_node * __init xbc_add_sibling(char *data, u32 flag)
sib->next = xbc_node_index(node);
}
}
- }
+ } else
+ xbc_parse_error("Too many nodes", data);
return node;
}
@@ -657,8 +658,10 @@ static int __init xbc_verify_tree(void)
struct xbc_node *n, *m;
/* Empty tree */
- if (xbc_node_num == 0)
+ if (xbc_node_num == 0) {
+ xbc_parse_error("Empty config", xbc_data);
return -ENOENT;
+ }
for (i = 0; i < xbc_node_num; i++) {
if (xbc_nodes[i].next > xbc_node_num) {
@@ -732,12 +735,17 @@ int __init xbc_init(char *buf)
char *p, *q;
int ret, c;
- if (xbc_data)
+ if (xbc_data) {
+ pr_err("Error: bootconfig is already initialized.\n");
return -EBUSY;
+ }
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;
+ }
xbc_data = buf;
xbc_data_size = ret + 1;
--
2.24.1
next prev parent reply other threads:[~2020-02-05 22:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-05 22:21 [for-next][PATCH 0/5] tracing: Really, this is the last update for 5.6 before my pull request! Steven Rostedt
2020-02-05 22:21 ` [for-next][PATCH 1/5] ftrace: Protect ftrace_graph_hash with ftrace_sync Steven Rostedt
2020-02-05 22:28 ` Paul E. McKenney
2020-02-05 22:21 ` [for-next][PATCH 2/5] bootconfig: Use bootconfig instead of boot config Steven Rostedt
2020-02-05 22:21 ` Steven Rostedt [this message]
2020-02-05 22:21 ` [for-next][PATCH 4/5] tools/bootconfig: Show the number of bootconfig nodes Steven Rostedt
2020-02-05 22:21 ` [for-next][PATCH 5/5] bootconfig: Show the number of nodes on boot message Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200205222143.086800401@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox