CC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Masami Hiramatsu <[email protected]>
CC: "Steven Rostedt (VMware)" <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git 
for-next
head:   384c54408efaa4b3298f42e54b8048b8045f253a
commit: bdac5c2b243f68ec15f8203c3348ae79fee8e8d8 [34/81] bootconfig: Allocate 
xbc_data inside xbc_init()
:::::: branch date: 12 hours ago
:::::: commit date: 2 weeks ago
config: i386-randconfig-c001-20211021 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 
3cea2505fd8d99a9ba0cb625aecfe28a47c4e3f8)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git/commit/?id=bdac5c2b243f68ec15f8203c3348ae79fee8e8d8
        git remote add rostedt-trace 
https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
        git fetch --no-tags rostedt-trace for-next
        git checkout bdac5c2b243f68ec15f8203c3348ae79fee8e8d8
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


clang-analyzer warnings: (new ones prefixed by >>)
   lib/bootconfig.c:881:10: note: Calling 'xbc_parse_kv'
                           ret = xbc_parse_kv(&p, q, c);
                                 ^~~~~~~~~~~~~~~~~~~~~~
   lib/bootconfig.c:635:6: note: 'ret' is 0
           if (ret)
               ^~~
   lib/bootconfig.c:635:2: note: Taking false branch
           if (ret)
           ^
   lib/bootconfig.c:638:6: note: Calling '__xbc_parse_value'
           c = __xbc_parse_value(&v, &next);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/bootconfig.c:500:6: note: Value assigned to 'xbc_nodes'
           v = skip_spaces(v);
               ^~~~~~~~~~~~~~
   lib/bootconfig.c:501:9: note: Assuming the condition is false
           while (*v == '#') {
                  ^~~~~~~~~
   lib/bootconfig.c:501:2: note: Loop condition is false. Execution continues 
on line 505
           while (*v == '#') {
           ^
   lib/bootconfig.c:505:6: note: Assuming the condition is false
           if (*v == '"' || *v == '\'') {
               ^~~~~~~~~
   lib/bootconfig.c:505:6: note: Left side of '||' is false
   lib/bootconfig.c:505:19: note: Assuming the condition is false
           if (*v == '"' || *v == '\'') {
                            ^~~~~~~~~~
   lib/bootconfig.c:505:2: note: Taking false branch
           if (*v == '"' || *v == '\'') {
           ^
   lib/bootconfig.c:510:2: note: Loop condition is false. Execution continues 
on line 532
           while ((c = *++p)) {
           ^
   lib/bootconfig.c:532:6: note: 'quotes' is 0
           if (quotes)
               ^~~~~~
   lib/bootconfig.c:532:2: note: Taking false branch
           if (quotes)
           ^
   lib/bootconfig.c:534:2: note: Taking false branch
           if (c == '#') {
           ^
   lib/bootconfig.c:638:6: note: Returning from '__xbc_parse_value'
           c = __xbc_parse_value(&v, &next);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/bootconfig.c:639:6: note: 'c' is >= 0
           if (c < 0)
               ^
   lib/bootconfig.c:639:2: note: Taking false branch
           if (c < 0)
           ^
   lib/bootconfig.c:643:6: note: Assuming 'child' is null
           if (child && xbc_node_is_value(child)) {
               ^~~~~
   lib/bootconfig.c:643:12: note: Left side of '&&' is false
           if (child && xbc_node_is_value(child)) {
                     ^
   lib/bootconfig.c:657:7: note: Calling 'xbc_add_head_sibling'
           if (!xbc_add_head_sibling(v, XBC_VALUE))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/bootconfig.c:422:9: note: Calling '__xbc_add_sibling'
           return __xbc_add_sibling(data, flag, true);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/bootconfig.c:390:32: note: Calling 'xbc_add_node'
           struct xbc_node *sib, *node = xbc_add_node(data, flag);
                                         ^~~~~~~~~~~~~~~~~~~~~~~~
   lib/bootconfig.c:362:6: note: Assuming 'xbc_node_num' is not equal to 
XBC_NODE_MAX
           if (xbc_node_num == XBC_NODE_MAX)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/bootconfig.c:362:2: note: Taking false branch
           if (xbc_node_num == XBC_NODE_MAX)
           ^
   lib/bootconfig.c:365:2: note: Null pointer value stored to 'node'
           node = &xbc_nodes[xbc_node_num++];
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/bootconfig.c:366:20: note: Passing null pointer value via 1st parameter 
'node'
           if (xbc_init_node(node, data, flag) < 0)
                             ^~~~
   lib/bootconfig.c:366:6: note: Calling 'xbc_init_node'
           if (xbc_init_node(node, data, flag) < 0)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/bootconfig.c:348:14: note: Assuming the condition is false
           if (WARN_ON(offset >= XBC_DATA_MAX))
                       ^
   include/asm-generic/bug.h:121:25: note: expanded from macro 'WARN_ON'
           int __ret_warn_on = !!(condition);                              \
                                  ^~~~~~~~~
   lib/bootconfig.c:348:6: note: Taking false branch
           if (WARN_ON(offset >= XBC_DATA_MAX))
               ^
   include/asm-generic/bug.h:122:2: note: expanded from macro 'WARN_ON'
           if (unlikely(__ret_warn_on))                                    \
           ^
   lib/bootconfig.c:348:2: note: Taking false branch
           if (WARN_ON(offset >= XBC_DATA_MAX))
           ^
   lib/bootconfig.c:351:13: note: Access to field 'data' results in a 
dereference of a null pointer (loaded from variable 'node')
           node->data = (u16)offset | flag;
           ~~~~       ^
>> lib/bootconfig.c:897:11: warning: Branch condition evaluates to a garbage 
>> value [clang-analyzer-core.uninitialized.Branch]
           } while (!ret);
                    ^~~~
   lib/bootconfig.c:819:6: note: 'ret' declared without an initial value
           int ret, c;
               ^~~
   lib/bootconfig.c:821:6: note: Assuming 'epos' is null
           if (epos)
               ^~~~
   lib/bootconfig.c:821:2: note: Taking false branch
           if (epos)
           ^
   lib/bootconfig.c:824:6: note: Assuming 'xbc_data' is null
           if (xbc_data) {
               ^~~~~~~~
   lib/bootconfig.c:824:2: note: Taking false branch
           if (xbc_data) {
           ^
   lib/bootconfig.c:829:6: note: Assuming the condition is false
           if (size > XBC_DATA_MAX || size == 0) {
               ^~~~~~~~~~~~~~~~~~~
   lib/bootconfig.c:829:6: note: Left side of '||' is false
   lib/bootconfig.c:829:29: note: Assuming 'size' is not equal to 0
           if (size > XBC_DATA_MAX || size == 0) {
                                      ^~~~~~~~~
   lib/bootconfig.c:829:2: note: Taking false branch
           if (size > XBC_DATA_MAX || size == 0) {
           ^
   lib/bootconfig.c:837:6: note: Assuming 'xbc_data' is non-null
           if (!xbc_data) {
               ^~~~~~~~~
   lib/bootconfig.c:837:2: note: Taking false branch
           if (!xbc_data) {
           ^
   lib/bootconfig.c:848:6: note: Assuming 'xbc_nodes' is non-null
           if (!xbc_nodes) {
               ^~~~~~~~~~
   lib/bootconfig.c:848:2: note: Taking false branch
           if (!xbc_nodes) {
           ^
   lib/bootconfig.c:860:7: note: Assuming 'q' is non-null
                   if (!q) {
                       ^~
   lib/bootconfig.c:860:3: note: Taking false branch
                   if (!q) {
                   ^
   lib/bootconfig.c:869:3: note: 'Default' branch taken. Execution continues on 
line 897
                   switch (c) {
                   ^
   lib/bootconfig.c:897:11: note: Branch condition evaluates to a garbage value
           } while (!ret);
                    ^~~~
   lib/bootconfig.c:899:6: warning: Branch condition evaluates to a garbage 
value [clang-analyzer-core.uninitialized.Branch]
           if (!ret)
               ^~~~
   lib/bootconfig.c:819:6: note: 'ret' declared without an initial value
           int ret, c;
               ^~~
   lib/bootconfig.c:821:6: note: Assuming 'epos' is null
           if (epos)
               ^~~~
   lib/bootconfig.c:821:2: note: Taking false branch
           if (epos)
           ^
   lib/bootconfig.c:824:6: note: Assuming 'xbc_data' is null
           if (xbc_data) {
               ^~~~~~~~
   lib/bootconfig.c:824:2: note: Taking false branch
           if (xbc_data) {
           ^
   lib/bootconfig.c:829:6: note: Assuming the condition is false
           if (size > XBC_DATA_MAX || size == 0) {
               ^~~~~~~~~~~~~~~~~~~
   lib/bootconfig.c:829:6: note: Left side of '||' is false
   lib/bootconfig.c:829:29: note: Assuming 'size' is not equal to 0
           if (size > XBC_DATA_MAX || size == 0) {
                                      ^~~~~~~~~
   lib/bootconfig.c:829:2: note: Taking false branch
           if (size > XBC_DATA_MAX || size == 0) {
           ^
   lib/bootconfig.c:837:6: note: Assuming 'xbc_data' is non-null
           if (!xbc_data) {
               ^~~~~~~~~
   lib/bootconfig.c:837:2: note: Taking false branch
           if (!xbc_data) {
           ^
   lib/bootconfig.c:848:6: note: Assuming 'xbc_nodes' is non-null
           if (!xbc_nodes) {
               ^~~~~~~~~~
   lib/bootconfig.c:848:2: note: Taking false branch
           if (!xbc_nodes) {
           ^
   lib/bootconfig.c:860:7: note: Assuming 'q' is null
                   if (!q) {
                       ^~
   lib/bootconfig.c:860:3: note: Taking true branch
                   if (!q) {
                   ^
   lib/bootconfig.c:862:8: note: Assuming the condition is false
                           if (*p != '\0')
                               ^~~~~~~~~~

vim +897 lib/bootconfig.c

76db5a27a827c2c Masami Hiramatsu 2020-01-11  800  
76db5a27a827c2c Masami Hiramatsu 2020-01-11  801  /**
76db5a27a827c2c Masami Hiramatsu 2020-01-11  802   * xbc_init() - Parse given 
XBC file and build XBC internal tree
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  803   * @data: The boot config 
text original data
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  804   * @size: The size of @data
89b74cac7834734 Masami Hiramatsu 2020-03-03  805   * @emsg: A pointer of const 
char * to store the error message
89b74cac7834734 Masami Hiramatsu 2020-03-03  806   * @epos: A pointer of int to 
store the error position
76db5a27a827c2c Masami Hiramatsu 2020-01-11  807   *
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  808   * This parses the boot 
config text in @data. @size must be smaller
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  809   * than XBC_DATA_MAX.
0f0d0a77ccbdc6b Masami Hiramatsu 2020-02-05  810   * Return the number of 
stored nodes (>0) if succeeded, or -errno
0f0d0a77ccbdc6b Masami Hiramatsu 2020-02-05  811   * if there is any error.
89b74cac7834734 Masami Hiramatsu 2020-03-03  812   * In error cases, @emsg will 
be updated with an error message and
89b74cac7834734 Masami Hiramatsu 2020-03-03  813   * @epos will be updated with 
the error position which is the byte offset
89b74cac7834734 Masami Hiramatsu 2020-03-03  814   * of @buf. If the error is 
not a parser error, @epos will be -1.
76db5a27a827c2c Masami Hiramatsu 2020-01-11  815   */
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  816  int __init xbc_init(const 
char *data, size_t size, const char **emsg, int *epos)
76db5a27a827c2c Masami Hiramatsu 2020-01-11  817  {
76db5a27a827c2c Masami Hiramatsu 2020-01-11  818        char *p, *q;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  819        int ret, c;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  820  
89b74cac7834734 Masami Hiramatsu 2020-03-03  821        if (epos)
89b74cac7834734 Masami Hiramatsu 2020-03-03  822                *epos = -1;
89b74cac7834734 Masami Hiramatsu 2020-03-03  823  
597c0e3b4540972 Masami Hiramatsu 2020-02-05  824        if (xbc_data) {
89b74cac7834734 Masami Hiramatsu 2020-03-03  825                if (emsg)
89b74cac7834734 Masami Hiramatsu 2020-03-03  826                        *emsg = 
"Bootconfig is already initialized";
76db5a27a827c2c Masami Hiramatsu 2020-01-11  827                return -EBUSY;
597c0e3b4540972 Masami Hiramatsu 2020-02-05  828        }
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  829        if (size > XBC_DATA_MAX 
|| size == 0) {
89b74cac7834734 Masami Hiramatsu 2020-03-03  830                if (emsg)
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  831                        *emsg = 
size ? "Config data is too big" :
89b74cac7834734 Masami Hiramatsu 2020-03-03  832                                
"Config data is empty";
76db5a27a827c2c Masami Hiramatsu 2020-01-11  833                return -ERANGE;
597c0e3b4540972 Masami Hiramatsu 2020-02-05  834        }
76db5a27a827c2c Masami Hiramatsu 2020-01-11  835  
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  836        xbc_data = 
memblock_alloc(size + 1, SMP_CACHE_BYTES);
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  837        if (!xbc_data) {
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  838                if (emsg)
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  839                        *emsg = 
"Failed to allocate bootconfig data";
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  840                return -ENOMEM;
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  841        }
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  842        memcpy(xbc_data, data, 
size);
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  843        xbc_data[size] = '\0';
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  844        xbc_data_size = size + 
1;
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  845  
a91e4f12ffc42fa Masami Hiramatsu 2020-02-07  846        xbc_nodes = 
memblock_alloc(sizeof(struct xbc_node) * XBC_NODE_MAX,
a91e4f12ffc42fa Masami Hiramatsu 2020-02-07  847                                
   SMP_CACHE_BYTES);
a91e4f12ffc42fa Masami Hiramatsu 2020-02-07  848        if (!xbc_nodes) {
89b74cac7834734 Masami Hiramatsu 2020-03-03  849                if (emsg)
89b74cac7834734 Masami Hiramatsu 2020-03-03  850                        *emsg = 
"Failed to allocate bootconfig nodes";
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  851                
xbc_destroy_all();
a91e4f12ffc42fa Masami Hiramatsu 2020-02-07  852                return -ENOMEM;
a91e4f12ffc42fa Masami Hiramatsu 2020-02-07  853        }
a91e4f12ffc42fa Masami Hiramatsu 2020-02-07  854        memset(xbc_nodes, 0, 
sizeof(struct xbc_node) * XBC_NODE_MAX);
76db5a27a827c2c Masami Hiramatsu 2020-01-11  855  
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  856        last_parent = NULL;
bdac5c2b243f68e Masami Hiramatsu 2021-09-16  857        p = xbc_data;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  858        do {
a2de2f86ae38317 Masami Hiramatsu 2020-07-16  859                q = strpbrk(p, 
"{}=+;:\n#");
76db5a27a827c2c Masami Hiramatsu 2020-01-11  860                if (!q) {
76db5a27a827c2c Masami Hiramatsu 2020-01-11  861                        p = 
skip_spaces(p);
76db5a27a827c2c Masami Hiramatsu 2020-01-11  862                        if (*p 
!= '\0')
76db5a27a827c2c Masami Hiramatsu 2020-01-11  863                                
ret = xbc_parse_error("No delimiter", p);
76db5a27a827c2c Masami Hiramatsu 2020-01-11  864                        break;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  865                }
76db5a27a827c2c Masami Hiramatsu 2020-01-11  866  
76db5a27a827c2c Masami Hiramatsu 2020-01-11  867                c = *q;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  868                *q++ = '\0';
76db5a27a827c2c Masami Hiramatsu 2020-01-11  869                switch (c) {
a2de2f86ae38317 Masami Hiramatsu 2020-07-16  870                case ':':
5f811c57c99205e Masami Hiramatsu 2020-02-21  871                case '+':
5f811c57c99205e Masami Hiramatsu 2020-02-21  872                        if 
(*q++ != '=') {
a2de2f86ae38317 Masami Hiramatsu 2020-07-16  873                                
ret = xbc_parse_error(c == '+' ?
a2de2f86ae38317 Masami Hiramatsu 2020-07-16  874                                
                "Wrong '+' operator" :
a2de2f86ae38317 Masami Hiramatsu 2020-07-16  875                                
                "Wrong ':' operator",
5f811c57c99205e Masami Hiramatsu 2020-02-21  876                                
                        q - 2);
5f811c57c99205e Masami Hiramatsu 2020-02-21  877                                
break;
5f811c57c99205e Masami Hiramatsu 2020-02-21  878                        }
4c1ca831adb1010 Nick Desaulniers 2020-11-15  879                        
fallthrough;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  880                case '=':
5f811c57c99205e Masami Hiramatsu 2020-02-21  881                        ret = 
xbc_parse_kv(&p, q, c);
76db5a27a827c2c Masami Hiramatsu 2020-01-11  882                        break;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  883                case '{':
76db5a27a827c2c Masami Hiramatsu 2020-01-11  884                        ret = 
xbc_open_brace(&p, q);
76db5a27a827c2c Masami Hiramatsu 2020-01-11  885                        break;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  886                case '#':
76db5a27a827c2c Masami Hiramatsu 2020-01-11  887                        q = 
skip_comment(q);
4c1ca831adb1010 Nick Desaulniers 2020-11-15  888                        
fallthrough;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  889                case ';':
76db5a27a827c2c Masami Hiramatsu 2020-01-11  890                case '\n':
76db5a27a827c2c Masami Hiramatsu 2020-01-11  891                        ret = 
xbc_parse_key(&p, q);
76db5a27a827c2c Masami Hiramatsu 2020-01-11  892                        break;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  893                case '}':
76db5a27a827c2c Masami Hiramatsu 2020-01-11  894                        ret = 
xbc_close_brace(&p, q);
76db5a27a827c2c Masami Hiramatsu 2020-01-11  895                        break;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  896                }
76db5a27a827c2c Masami Hiramatsu 2020-01-11 @897        } while (!ret);
76db5a27a827c2c Masami Hiramatsu 2020-01-11  898  
76db5a27a827c2c Masami Hiramatsu 2020-01-11  899        if (!ret)
76db5a27a827c2c Masami Hiramatsu 2020-01-11  900                ret = 
xbc_verify_tree();
76db5a27a827c2c Masami Hiramatsu 2020-01-11  901  
89b74cac7834734 Masami Hiramatsu 2020-03-03  902        if (ret < 0) {
89b74cac7834734 Masami Hiramatsu 2020-03-03  903                if (epos)
89b74cac7834734 Masami Hiramatsu 2020-03-03  904                        *epos = 
xbc_err_pos;
89b74cac7834734 Masami Hiramatsu 2020-03-03  905                if (emsg)
89b74cac7834734 Masami Hiramatsu 2020-03-03  906                        *emsg = 
xbc_err_msg;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  907                
xbc_destroy_all();
89b74cac7834734 Masami Hiramatsu 2020-03-03  908        } else
0f0d0a77ccbdc6b Masami Hiramatsu 2020-02-05  909                ret = 
xbc_node_num;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  910  
76db5a27a827c2c Masami Hiramatsu 2020-01-11  911        return ret;
76db5a27a827c2c Masami Hiramatsu 2020-01-11  912  }
76db5a27a827c2c Masami Hiramatsu 2020-01-11  913  

:::::: The code at line 897 was first introduced by commit
:::::: 76db5a27a827c2c89e5120a3d486472da847863b bootconfig: Add Extra Boot 
Config support

:::::: TO: Masami Hiramatsu <[email protected]>
:::::: CC: Steven Rostedt (VMware) <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to