public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [rostedt-trace:ftrace/core 2/2] kernel/trace/pid_list.c:439:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]
       [not found] <202109300520.e7Cli09Z-lkp@intel.com>
@ 2021-10-10  9:46 ` kernel test robot
  2021-10-11 15:52   ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2021-10-10  9:46 UTC (permalink / raw)
  To: Steven Rostedt (VMware); +Cc: llvm, kbuild-all, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 9204 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git ftrace/core
head:   c8d01c02b46e599b057d7d24d1342ae9fcf828c2
commit: c8d01c02b46e599b057d7d24d1342ae9fcf828c2 [2/2] tracing: Create a sparse bitmask for pid filtering
config: riscv-randconfig-c006-20210927 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dc6e8dfdfe7efecfda318d43a06fae18b40eb498)
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 riscv cross compiling tool for clang build
         # apt-get install binutils-riscv64-linux-gnu
         # https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git/commit/?id=c8d01c02b46e599b057d7d24d1342ae9fcf828c2
         git remote add rostedt-trace https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
         git fetch --no-tags rostedt-trace ftrace/core
         git checkout c8d01c02b46e599b057d7d24d1342ae9fcf828c2
         # save the attached .config to linux build tree
         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)

 >> kernel/trace/pid_list.c:439:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]
            if (upper) {
                ^~~~~
    kernel/trace/pid_list.c:398:2: note: 'upper' declared without an initial value
            union upper_chunk *upper;
            ^~~~~~~~~~~~~~~~~~~~~~~~
    kernel/trace/pid_list.c:413:6: note: Assuming 'upper_count' is > 0
            if (upper_count <= 0 && lower_count <= 0)
                ^~~~~~~~~~~~~~~~
    kernel/trace/pid_list.c:413:23: note: Left side of '&&' is false
            if (upper_count <= 0 && lower_count <= 0)
                                 ^
    kernel/trace/pid_list.c:416:2: note: Loop condition is true.  Entering loop body
            while (upper_count-- > 0) {
            ^
    kernel/trace/pid_list.c:420:7: note: Assuming 'chunk' is null
                    if (!chunk)
                        ^~~~~~
    kernel/trace/pid_list.c:420:3: note: Taking true branch
                    if (!chunk)
                    ^
    kernel/trace/pid_list.c:421:4: note:  Execution continues on line 427
                            break;
                            ^
    kernel/trace/pid_list.c:427:9: note: Assuming the condition is false
            while (lower_count-- > 0) {
                   ^~~~~~~~~~~~~~~~~
    kernel/trace/pid_list.c:427:2: note: Loop condition is false. Execution continues on line 438
            while (lower_count-- > 0) {
            ^
    kernel/trace/pid_list.c:439:6: note: Branch condition evaluates to a garbage value
            if (upper) {
                ^~~~~
    kernel/trace/pid_list.c:444:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]
            if (lower) {
                ^~~~~

vim +439 kernel/trace/pid_list.c

c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  393)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  394) static void pid_list_refill_irq(struct irq_work *iwork)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  395) {
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  396) 	struct trace_pid_list *pid_list = container_of(iwork, struct trace_pid_list,
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  397) 						       refill_irqwork);
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  398) 	union upper_chunk *upper;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  399) 	union lower_chunk *lower;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  400) 	union upper_chunk **upper_next = &upper;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  401) 	union lower_chunk **lower_next = &lower;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  402) 	int upper_count;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  403) 	int lower_count;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  404) 	int ucnt = 0;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  405) 	int lcnt = 0;
eff05923d317af7 Steven Rostedt (VMware  2021-09-23  406)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  407)  again:
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  408) 	raw_spin_lock(&pid_list->lock);
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  409) 	upper_count = CHUNK_ALLOC - pid_list->free_upper_chunks;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  410) 	lower_count = CHUNK_ALLOC - pid_list->free_lower_chunks;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  411) 	raw_spin_unlock(&pid_list->lock);
eff05923d317af7 Steven Rostedt (VMware  2021-09-23  412)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  413) 	if (upper_count <= 0 && lower_count <= 0)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  414) 		return;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  415)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  416) 	while (upper_count-- > 0) {
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  417) 		union upper_chunk *chunk;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  418)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  419) 		chunk = kzalloc(sizeof(*chunk), GFP_KERNEL);
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  420) 		if (!chunk)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  421) 			break;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  422) 		*upper_next = chunk;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  423) 		upper_next = &chunk->next;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  424) 		ucnt++;
eff05923d317af7 Steven Rostedt (VMware  2021-09-23  425) 	}
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  426)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  427) 	while (lower_count-- > 0) {
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  428) 		union lower_chunk *chunk;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  429)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  430) 		chunk = kzalloc(sizeof(*chunk), GFP_KERNEL);
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  431) 		if (!chunk)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  432) 			break;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  433) 		*lower_next = chunk;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  434) 		lower_next = &chunk->next;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  435) 		lcnt++;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  436) 	}
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  437)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  438) 	raw_spin_lock(&pid_list->lock);
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23 @439) 	if (upper) {
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  440) 		*upper_next = pid_list->upper_list;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  441) 		pid_list->upper_list = upper;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  442) 		pid_list->free_upper_chunks += ucnt;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  443) 	}
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  444) 	if (lower) {
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  445) 		*lower_next = pid_list->lower_list;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  446) 		pid_list->lower_list = lower;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  447) 		pid_list->free_lower_chunks += lcnt;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  448) 	}
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  449) 	raw_spin_unlock(&pid_list->lock);
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  450)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  451) 	/*
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  452) 	 * On success of allocating all the chunks, both counters
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  453) 	 * will be less than zero. If they are not, then an allocation
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  454) 	 * failed, and we should not try again.
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  455) 	 */
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  456) 	if (upper_count >= 0 || lower_count >= 0)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  457) 		return;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  458) 	/*
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  459) 	 * When the locks were released, free chunks could have
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  460) 	 * been used and allocation needs to be done again. Might as
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  461) 	 * well allocate it now.
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  462) 	 */
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  463) 	goto again;
eff05923d317af7 Steven Rostedt (VMware  2021-09-23  464) }
eff05923d317af7 Steven Rostedt (VMware  2021-09-23  465)

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34157 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [rostedt-trace:ftrace/core 2/2] kernel/trace/pid_list.c:439:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]
  2021-10-10  9:46 ` [rostedt-trace:ftrace/core 2/2] kernel/trace/pid_list.c:439:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch] kernel test robot
@ 2021-10-11 15:52   ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2021-10-11 15:52 UTC (permalink / raw)
  To: kernel test robot; +Cc: llvm, kbuild-all, Linux Kernel Mailing List

On Sun, 10 Oct 2021 17:46:20 +0800
kernel test robot <yujie.liu@intel.com> wrote:

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git ftrace/core
> head:   c8d01c02b46e599b057d7d24d1342ae9fcf828c2
> commit: c8d01c02b46e599b057d7d24d1342ae9fcf828c2 [2/2] tracing: Create a sparse bitmask for pid filtering
> config: riscv-randconfig-c006-20210927 (attached as .config)
> compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dc6e8dfdfe7efecfda318d43a06fae18b40eb498)
> 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 riscv cross compiling tool for clang build
>          # apt-get install binutils-riscv64-linux-gnu
>          # https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git/commit/?id=c8d01c02b46e599b057d7d24d1342ae9fcf828c2
>          git remote add rostedt-trace https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
>          git fetch --no-tags rostedt-trace ftrace/core
>          git checkout c8d01c02b46e599b057d7d24d1342ae9fcf828c2
>          # save the attached .config to linux build tree
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>


Thanks, this was already reported.

  https://lore.kernel.org/all/221bc7ba-a475-1cb9-1bbe-730bb9c2d448@canonical.com/

-- Steve


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-11 15:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <202109300520.e7Cli09Z-lkp@intel.com>
2021-10-10  9:46 ` [rostedt-trace:ftrace/core 2/2] kernel/trace/pid_list.c:439:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch] kernel test robot
2021-10-11 15:52   ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox