Re: [GIT PULL] bootconfig: Fixes for v7.0-rc4

From: Josh Law

Date: Sat Mar 21 2026 - 10:00:04 EST


On 2026-03-21, mhiramat@xxxxxxxxxx wrote:
> Hi Linus,
>
> Bootconfig fixes for v7.0-rc4
>
> - lib/bootconfig: check xbc_init_node() return in override path
> Fix to check error code of xbc_init_node() in override value path
> in xbc_parse_kv().
> - tools/bootconfig: fix fd leak in load_xbc_file() on fstat failure
> Fix to close fd in fstat() failure path.
>
>
> Please pull the latest bootconfig-fixes-v7.0-rc4 tree, which can be found at:
>
>
> git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
> bootconfig-fixes-v7.0-rc4
>
> Tag SHA1: a701749c7ddb8ebc9b7a5cd94118b8365bb107ea
> Head SHA1: 3b2c2ab4ceb82af484310c3087541eab00ea288b
>
>
> Josh Law (2):
> lib/bootconfig: check xbc_init_node() return in override path
> tools/bootconfig: fix fd leak in load_xbc_file() on fstat failure
>
> ----
> lib/bootconfig.c | 3 ++-
> tools/bootconfig/main.c | 7 +++++--
> 2 files changed, 7 insertions(+), 3 deletions(-)
> ---------------------------
> diff --git a/lib/bootconfig.c b/lib/bootconfig.c
> index 2da049216fe0..e88d0221a826 100644
> --- a/lib/bootconfig.c
> +++ b/lib/bootconfig.c
> @@ -723,7 +723,8 @@ static int __init xbc_parse_kv(char **k, char *v, int op)
> if (op == ':') {
> unsigned short nidx = child->next;
>
> - xbc_init_node(child, v, XBC_VALUE);
> + if (xbc_init_node(child, v, XBC_VALUE) < 0)
> + return xbc_parse_error("Failed to override value", v);
> child->next = nidx; /* keep subkeys */
> goto array;
> }
> diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
> index 55d59ed507d5..643f707b8f1d 100644
> --- a/tools/bootconfig/main.c
> +++ b/tools/bootconfig/main.c
> @@ -162,8 +162,11 @@ static int load_xbc_file(const char *path, char **buf)
> if (fd < 0)
> return -errno;
> ret = fstat(fd, &stat);
> - if (ret < 0)
> - return -errno;
> + if (ret < 0) {
> + ret = -errno;
> + close(fd);
> + return ret;
> + }
>
> ret = load_xbc_fd(fd, buf, stat.st_size);
>
>
> --
> Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
>

Thanks masami!

V/R

Josh Law