CC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Christophe Leroy <[email protected]>
CC: Michael Ellerman <[email protected]>

tree:   https://github.com/linuxppc/linux next-test
head:   579a7abaf051ef84dd24cf19e6541455e7df72ce
commit: 1e688dd2a3d6759d416616ff07afc4bb836c4213 [71/92] powerpc/bug: Provide 
better flexibility to WARN_ON/__WARN_FLAGS() with asm goto
:::::: branch date: 26 hours ago
:::::: commit date: 7 days ago
config: powerpc-randconfig-c003-20210821 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 
d9c5613e856cf2addfbf892fc4c1ce9ef9feceaa)
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
        # install powerpc cross compiling tool for clang build
        # apt-get install binutils-powerpc-linux-gnu
        # 
https://github.com/linuxppc/linux/commit/1e688dd2a3d6759d416616ff07afc4bb836c4213
        git remote add linuxppc https://github.com/linuxppc/linux
        git fetch --no-tags linuxppc next-test
        git checkout 1e688dd2a3d6759d416616ff07afc4bb836c4213
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc 
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 >>)
           ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to 
see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 
'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro 
'_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:306:2: note: expanded from macro 
'__compiletime_assert'
           do {                                                            \
           ^
   drivers/of/irq.c:558:7: note: Assuming 'desc' is null
                   if (!desc) {
                       ^~~~~
   drivers/of/irq.c:558:3: note: Taking true branch
                   if (!desc) {
                   ^
   drivers/of/irq.c:560:4: note:  Execution continues on line 567
                           break;
                           ^
   drivers/of/irq.c:567:2: note: Left side of '&&' is false
           list_for_each_entry_safe(desc, temp_desc, &intc_parent_list, list) {
           ^
   include/linux/list.h:715:13: note: expanded from macro 
'list_for_each_entry_safe'
           for (pos = list_first_entry(head, typeof(*pos), member),        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   drivers/of/irq.c:567:2: note: Taking false branch
           list_for_each_entry_safe(desc, temp_desc, &intc_parent_list, list) {
           ^
   include/linux/list.h:715:13: note: expanded from macro 
'list_for_each_entry_safe'
           for (pos = list_first_entry(head, typeof(*pos), member),        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to 
see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 
'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro 
'_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro 
'__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   drivers/of/irq.c:567:2: note: Loop condition is false.  Exiting loop
           list_for_each_entry_safe(desc, temp_desc, &intc_parent_list, list) {
           ^
   include/linux/list.h:715:13: note: expanded from macro 
'list_for_each_entry_safe'
           for (pos = list_first_entry(head, typeof(*pos), member),        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to 
see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 
'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro 
'_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:306:2: note: expanded from macro 
'__compiletime_assert'
           do {                                                            \
           ^
   drivers/of/irq.c:567:27: note: Null pointer value stored to 'desc'
           list_for_each_entry_safe(desc, temp_desc, &intc_parent_list, list) {
                                    ^
   include/linux/list.h:715:7: note: expanded from macro 
'list_for_each_entry_safe'
           for (pos = list_first_entry(head, typeof(*pos), member),        \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/of/irq.c:567:2: note: Dereference of null pointer
           list_for_each_entry_safe(desc, temp_desc, &intc_parent_list, list) {
           ^
   include/linux/list.h:716:7: note: expanded from macro 
'list_for_each_entry_safe'
                   n = list_next_entry(pos, member);                       \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/list.h:555:2: note: expanded from macro 'list_next_entry'
           list_entry((pos)->member.next, typeof(*(pos)), member)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:494:25: note: expanded from macro 'container_of'
           void *__mptr = (void *)(ptr);                                   \
                                  ^~~~~
>> drivers/of/irq.c:567:2: warning: Use of memory after it is freed 
>> [clang-analyzer-unix.Malloc]
           list_for_each_entry_safe(desc, temp_desc, &intc_parent_list, list) {
           ^
   include/linux/list.h:716:7: note: expanded from macro 
'list_for_each_entry_safe'
                   n = list_next_entry(pos, member);                       \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/list.h:555:2: note: expanded from macro 'list_next_entry'
           list_entry((pos)->member.next, typeof(*(pos)), member)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:494:25: note: expanded from macro 'container_of'
           void *__mptr = (void *)(ptr);                                   \
                                  ^~~~~
   drivers/of/irq.c:489:2: note: Loop condition is true.  Entering loop body
           for_each_matching_node_and_match(np, matches, &match) {
           ^
   include/linux/of.h:1292:2: note: expanded from macro 
'for_each_matching_node_and_match'
           for (dn = of_find_matching_node_and_match(NULL, matches, match); \
           ^
   drivers/of/irq.c:490:7: note: Left side of '||' is false
                   if (!of_property_read_bool(np, "interrupt-controller") ||
                       ^
   drivers/of/irq.c:491:5: note: Assuming the condition is false
                                   !of_device_is_available(np))
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/of/irq.c:490:3: note: Taking false branch
                   if (!of_property_read_bool(np, "interrupt-controller") ||
                   ^
   drivers/of/irq.c:494:12: note: Assuming field 'data' is non-null
                   if (WARN(!match->data, "of_irq_init: no init function for 
%s\n",
                            ^
   include/asm-generic/bug.h:130:25: note: expanded from macro 'WARN'
           int __ret_warn_on = !!(condition);                              \
                                  ^~~~~~~~~
   drivers/of/irq.c:494:7: note: Taking false branch
                   if (WARN(!match->data, "of_irq_init: no init function for 
%s\n",
                       ^
   include/asm-generic/bug.h:131:2: note: expanded from macro 'WARN'
           if (unlikely(__ret_warn_on))                                    \
           ^
   drivers/of/irq.c:494:3: note: Taking false branch
                   if (WARN(!match->data, "of_irq_init: no init function for 
%s\n",
                   ^
   drivers/of/irq.c:503:7: note: Assuming 'desc' is non-null
                   if (!desc) {
                       ^~~~~
   drivers/of/irq.c:503:3: note: Taking false branch
                   if (!desc) {
                   ^
   drivers/of/irq.c:511:7: note: Assuming 'np' is equal to field 
'interrupt_parent'
                   if (desc->interrupt_parent == np)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/of/irq.c:511:3: note: Taking true branch
                   if (desc->interrupt_parent == np)
                   ^
   drivers/of/irq.c:489:2: note: Loop condition is true.  Entering loop body
           for_each_matching_node_and_match(np, matches, &match) {
           ^
   include/linux/of.h:1292:2: note: expanded from macro 
'for_each_matching_node_and_match'
           for (dn = of_find_matching_node_and_match(NULL, matches, match); \
           ^
   drivers/of/irq.c:490:7: note: Left side of '||' is false
                   if (!of_property_read_bool(np, "interrupt-controller") ||
                       ^
   drivers/of/irq.c:491:5: note: Assuming the condition is false
                                   !of_device_is_available(np))
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/of/irq.c:490:3: note: Taking false branch
                   if (!of_property_read_bool(np, "interrupt-controller") ||
                   ^
   drivers/of/irq.c:494:12: note: Assuming field 'data' is non-null
                   if (WARN(!match->data, "of_irq_init: no init function for 
%s\n",
                            ^
   include/asm-generic/bug.h:130:25: note: expanded from macro 'WARN'
           int __ret_warn_on = !!(condition);                              \
                                  ^~~~~~~~~
   drivers/of/irq.c:494:7: note: Taking false branch
                   if (WARN(!match->data, "of_irq_init: no init function for 
%s\n",
                       ^
   include/asm-generic/bug.h:131:2: note: expanded from macro 'WARN'
           if (unlikely(__ret_warn_on))                                    \
           ^
   drivers/of/irq.c:494:3: note: Taking false branch
                   if (WARN(!match->data, "of_irq_init: no init function for 
%s\n",
                   ^
   drivers/of/irq.c:503:7: note: Assuming 'desc' is non-null
                   if (!desc) {
                       ^~~~~
   drivers/of/irq.c:503:3: note: Taking false branch
                   if (!desc) {
                   ^
   drivers/of/irq.c:511:33: note: 'np' is not equal to field 'interrupt_parent'
                   if (desc->interrupt_parent == np)
                                                 ^~
   drivers/of/irq.c:511:3: note: Taking false branch
                   if (desc->interrupt_parent == np)
                   ^
   drivers/of/irq.c:489:2: note: Loop condition is false. Execution continues 
on line 521
           for_each_matching_node_and_match(np, matches, &match) {

vim +567 drivers/of/irq.c

c71a54b0820179 Rob Herring        2011-09-20  471  
c71a54b0820179 Rob Herring        2011-09-20  472  /**
c71a54b0820179 Rob Herring        2011-09-20  473   * of_irq_init - Scan and 
init matching interrupt controllers in DT
c71a54b0820179 Rob Herring        2011-09-20  474   * @matches: 0 terminated 
array of nodes to match and init function to call
c71a54b0820179 Rob Herring        2011-09-20  475   *
c71a54b0820179 Rob Herring        2011-09-20  476   * This function scans the 
device tree for matching interrupt controller nodes,
c71a54b0820179 Rob Herring        2011-09-20  477   * and calls their 
initialization functions in order with parents first.
c71a54b0820179 Rob Herring        2011-09-20  478   */
c71a54b0820179 Rob Herring        2011-09-20  479  void __init 
of_irq_init(const struct of_device_id *matches)
c71a54b0820179 Rob Herring        2011-09-20  480  {
264041e3796133 Masahiro Yamada    2015-11-24  481       const struct 
of_device_id *match;
c71a54b0820179 Rob Herring        2011-09-20  482       struct device_node *np, 
*parent = NULL;
48a9b733e644ab Geert Uytterhoeven 2015-06-26  483       struct of_intc_desc 
*desc, *temp_desc;
c71a54b0820179 Rob Herring        2011-09-20  484       struct list_head 
intc_desc_list, intc_parent_list;
c71a54b0820179 Rob Herring        2011-09-20  485  
c71a54b0820179 Rob Herring        2011-09-20  486       
INIT_LIST_HEAD(&intc_desc_list);
c71a54b0820179 Rob Herring        2011-09-20  487       
INIT_LIST_HEAD(&intc_parent_list);
c71a54b0820179 Rob Herring        2011-09-20  488  
264041e3796133 Masahiro Yamada    2015-11-24  489       
for_each_matching_node_and_match(np, matches, &match) {
6a245d959c7470 Sergei Shtylyov    2017-07-08  490               if 
(!of_property_read_bool(np, "interrupt-controller") ||
bf49be02d6f92b Peter Crosthwaite  2013-11-27  491                               
!of_device_is_available(np))
c71a54b0820179 Rob Herring        2011-09-20  492                       
continue;
264041e3796133 Masahiro Yamada    2015-11-24  493  
264041e3796133 Masahiro Yamada    2015-11-24  494               if 
(WARN(!match->data, "of_irq_init: no init function for %s\n",
264041e3796133 Masahiro Yamada    2015-11-24  495                        
match->compatible))
264041e3796133 Masahiro Yamada    2015-11-24  496                       
continue;
264041e3796133 Masahiro Yamada    2015-11-24  497  
c71a54b0820179 Rob Herring        2011-09-20  498               /*
48a9b733e644ab Geert Uytterhoeven 2015-06-26  499                * Here, we 
allocate and populate an of_intc_desc with the node
c71a54b0820179 Rob Herring        2011-09-20  500                * pointer, 
interrupt-parent device_node etc.
c71a54b0820179 Rob Herring        2011-09-20  501                */
c71a54b0820179 Rob Herring        2011-09-20  502               desc = 
kzalloc(sizeof(*desc), GFP_KERNEL);
6f7dc9a37f2b32 Geert Uytterhoeven 2019-05-02  503               if (!desc) {
8363ccb917c6bd Julia Lawall       2015-10-22  504                       
of_node_put(np);
c71a54b0820179 Rob Herring        2011-09-20  505                       goto 
err;
8363ccb917c6bd Julia Lawall       2015-10-22  506               }
c71a54b0820179 Rob Herring        2011-09-20  507  
264041e3796133 Masahiro Yamada    2015-11-24  508               
desc->irq_init_cb = match->data;
8363ccb917c6bd Julia Lawall       2015-10-22  509               desc->dev = 
of_node_get(np);
c71a54b0820179 Rob Herring        2011-09-20  510               
desc->interrupt_parent = of_irq_find_parent(np);
d7fb6d0adb86ed Rob Herring        2011-11-27  511               if 
(desc->interrupt_parent == np)
d7fb6d0adb86ed Rob Herring        2011-11-27  512                       
desc->interrupt_parent = NULL;
c71a54b0820179 Rob Herring        2011-09-20  513               
list_add_tail(&desc->list, &intc_desc_list);
c71a54b0820179 Rob Herring        2011-09-20  514       }
c71a54b0820179 Rob Herring        2011-09-20  515  
c71a54b0820179 Rob Herring        2011-09-20  516       /*
c71a54b0820179 Rob Herring        2011-09-20  517        * The root irq 
controller is the one without an interrupt-parent.
c71a54b0820179 Rob Herring        2011-09-20  518        * That one goes first, 
followed by the controllers that reference it,
c71a54b0820179 Rob Herring        2011-09-20  519        * followed by the ones 
that reference the 2nd level controllers, etc.
c71a54b0820179 Rob Herring        2011-09-20  520        */
c71a54b0820179 Rob Herring        2011-09-20  521       while 
(!list_empty(&intc_desc_list)) {
c71a54b0820179 Rob Herring        2011-09-20  522               /*
c71a54b0820179 Rob Herring        2011-09-20  523                * Process all 
controllers with the current 'parent'.
c71a54b0820179 Rob Herring        2011-09-20  524                * First pass 
will be looking for NULL as the parent.
c71a54b0820179 Rob Herring        2011-09-20  525                * The 
assumption is that NULL parent means a root controller.
c71a54b0820179 Rob Herring        2011-09-20  526                */
c71a54b0820179 Rob Herring        2011-09-20  527               
list_for_each_entry_safe(desc, temp_desc, &intc_desc_list, list) {
c71a54b0820179 Rob Herring        2011-09-20  528                       int ret;
c71a54b0820179 Rob Herring        2011-09-20  529  
c71a54b0820179 Rob Herring        2011-09-20  530                       if 
(desc->interrupt_parent != parent)
c71a54b0820179 Rob Herring        2011-09-20  531                               
continue;
c71a54b0820179 Rob Herring        2011-09-20  532  
c71a54b0820179 Rob Herring        2011-09-20  533                       
list_del(&desc->list);
c71a54b0820179 Rob Herring        2011-09-20  534  
e55aeb6ba4e8cc Philipp Zabel      2016-08-09  535                       
of_node_set_flag(desc->dev, OF_POPULATED);
e55aeb6ba4e8cc Philipp Zabel      2016-08-09  536  
0d638a07d3a1e9 Rob Herring        2017-06-01  537                       
pr_debug("of_irq_init: init %pOF (%p), parent %p\n",
0d638a07d3a1e9 Rob Herring        2017-06-01  538                               
 desc->dev,
c71a54b0820179 Rob Herring        2011-09-20  539                               
 desc->dev, desc->interrupt_parent);
264041e3796133 Masahiro Yamada    2015-11-24  540                       ret = 
desc->irq_init_cb(desc->dev,
264041e3796133 Masahiro Yamada    2015-11-24  541                               
                desc->interrupt_parent);
c71a54b0820179 Rob Herring        2011-09-20  542                       if 
(ret) {
e55aeb6ba4e8cc Philipp Zabel      2016-08-09  543                               
of_node_clear_flag(desc->dev, OF_POPULATED);
c71a54b0820179 Rob Herring        2011-09-20  544                               
kfree(desc);
c71a54b0820179 Rob Herring        2011-09-20  545                               
continue;
c71a54b0820179 Rob Herring        2011-09-20  546                       }
c71a54b0820179 Rob Herring        2011-09-20  547  
c71a54b0820179 Rob Herring        2011-09-20  548                       /*
c71a54b0820179 Rob Herring        2011-09-20  549                        * This 
one is now set up; add it to the parent list so
c71a54b0820179 Rob Herring        2011-09-20  550                        * its 
children can get processed in a subsequent pass.
c71a54b0820179 Rob Herring        2011-09-20  551                        */
c71a54b0820179 Rob Herring        2011-09-20  552                       
list_add_tail(&desc->list, &intc_parent_list);
c71a54b0820179 Rob Herring        2011-09-20  553               }
c71a54b0820179 Rob Herring        2011-09-20  554  
c71a54b0820179 Rob Herring        2011-09-20  555               /* Get the next 
pending parent that might have children */
c0cdfaa0a5e7a3 Axel Lin           2013-06-23  556               desc = 
list_first_entry_or_null(&intc_parent_list,
c0cdfaa0a5e7a3 Axel Lin           2013-06-23  557                               
                typeof(*desc), list);
c0cdfaa0a5e7a3 Axel Lin           2013-06-23  558               if (!desc) {
c71a54b0820179 Rob Herring        2011-09-20  559                       
pr_err("of_irq_init: children remain, but no parents\n");
c71a54b0820179 Rob Herring        2011-09-20  560                       break;
c71a54b0820179 Rob Herring        2011-09-20  561               }
c71a54b0820179 Rob Herring        2011-09-20  562               
list_del(&desc->list);
c71a54b0820179 Rob Herring        2011-09-20  563               parent = 
desc->dev;
c71a54b0820179 Rob Herring        2011-09-20  564               kfree(desc);
c71a54b0820179 Rob Herring        2011-09-20  565       }
c71a54b0820179 Rob Herring        2011-09-20  566  
c71a54b0820179 Rob Herring        2011-09-20 @567       
list_for_each_entry_safe(desc, temp_desc, &intc_parent_list, list) {
c71a54b0820179 Rob Herring        2011-09-20  568               
list_del(&desc->list);
c71a54b0820179 Rob Herring        2011-09-20  569               kfree(desc);
c71a54b0820179 Rob Herring        2011-09-20  570       }
c71a54b0820179 Rob Herring        2011-09-20  571  err:
c71a54b0820179 Rob Herring        2011-09-20  572       
list_for_each_entry_safe(desc, temp_desc, &intc_desc_list, list) {
c71a54b0820179 Rob Herring        2011-09-20  573               
list_del(&desc->list);
8363ccb917c6bd Julia Lawall       2015-10-22  574               
of_node_put(desc->dev);
c71a54b0820179 Rob Herring        2011-09-20  575               kfree(desc);
c71a54b0820179 Rob Herring        2011-09-20  576       }
c71a54b0820179 Rob Herring        2011-09-20  577  }
c706c239af5bc2 Marc Zyngier       2015-07-28  578  

:::::: The code at line 567 was first introduced by commit
:::::: c71a54b0820179e53483d5220cdef1a0df8d5bd1 of/irq: introduce of_irq_init

:::::: TO: Rob Herring <[email protected]>
:::::: CC: Arnd Bergmann <[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