Skip to content

Commit 55d55b9

Browse files
committed
Merge tag 'bootconfig-fixes-v7.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull bootconfig fixes from Masami Hiramatsu: - Check error code of xbc_init_node() in override value path in xbc_parse_kv() - Fix fd leak in load_xbc_file() on fstat failure * tag 'bootconfig-fixes-v7.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tools/bootconfig: fix fd leak in load_xbc_file() on fstat failure lib/bootconfig: check xbc_init_node() return in override path
2 parents 8991448 + 3b2c2ab commit 55d55b9

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

lib/bootconfig.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,8 @@ static int __init xbc_parse_kv(char **k, char *v, int op)
723723
if (op == ':') {
724724
unsigned short nidx = child->next;
725725

726-
xbc_init_node(child, v, XBC_VALUE);
726+
if (xbc_init_node(child, v, XBC_VALUE) < 0)
727+
return xbc_parse_error("Failed to override value", v);
727728
child->next = nidx; /* keep subkeys */
728729
goto array;
729730
}

tools/bootconfig/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,11 @@ static int load_xbc_file(const char *path, char **buf)
162162
if (fd < 0)
163163
return -errno;
164164
ret = fstat(fd, &stat);
165-
if (ret < 0)
166-
return -errno;
165+
if (ret < 0) {
166+
ret = -errno;
167+
close(fd);
168+
return ret;
169+
}
167170

168171
ret = load_xbc_fd(fd, buf, stat.st_size);
169172

0 commit comments

Comments
 (0)