Skip to content

Commit 39ebc8d

Browse files
techyguyperplexablemhiramat
authored andcommitted
lib/bootconfig: fix off-by-one in xbc_verify_tree() unclosed brace error
__xbc_open_brace() pushes entries with post-increment (open_brace[brace_index++]), so brace_index always points one past the last valid entry. xbc_verify_tree() reads open_brace[brace_index] to report which brace is unclosed, but this is one past the last pushed entry and contains stale/zero data, causing the error message to reference the wrong node. Use open_brace[brace_index - 1] to correctly identify the unclosed brace. brace_index is known to be > 0 here since we are inside the if (brace_index) guard. Link: https://lore.kernel.org/all/20260312191143.28719-2-objecting@objecting.org/ Fixes: ead1e19 ("lib/bootconfig: Fix a bug of breaking existing tree nodes") Cc: stable@vger.kernel.org Signed-off-by: Josh Law <objecting@objecting.org> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
1 parent 1f318b9 commit 39ebc8d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/bootconfig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ static int __init xbc_verify_tree(void)
802802

803803
/* Brace closing */
804804
if (brace_index) {
805-
n = &xbc_nodes[open_brace[brace_index]];
805+
n = &xbc_nodes[open_brace[brace_index - 1]];
806806
return xbc_parse_error("Brace is not closed",
807807
xbc_node_get_data(n));
808808
}

0 commit comments

Comments
 (0)