:::::: 
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check first_new_problem: 
include/linux/bio.h:563:35: warning: dereference of NULL '((struct bio_list 
*)rbio)[8].tail' [CWE-476] [-Wanalyzer-null-dereference]"
:::::: 

CC: [email protected]
BCC: [email protected]
CC: [email protected]
TO: Christoph Hellwig <[email protected]>
CC: David Sterba <[email protected]>
CC: Qu Wenruo <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   b13baccc3850ca8b8cccbf8ed9912dbaa0fdf7f3
commit: 385de0ef387dc7f33fc5b828136cbc9516b3ec1a btrfs: use a normal workqueue 
for rmw_workers
date:   4 weeks ago
:::::: branch date: 28 hours ago
:::::: commit date: 4 weeks ago
config: i386-randconfig-c001-20220613 
(https://download.01.org/0day-ci/archive/20220614/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
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/torvalds/linux.git/commit/?id=385de0ef387dc7f33fc5b828136cbc9516b3ec1a
        git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 385de0ef387dc7f33fc5b828136cbc9516b3ec1a
        # save the config file
         ARCH=i386 KBUILD_USERCFLAGS='-fanalyzer -Wno-error' 

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


gcc-analyzer warnings: (new ones prefixed by >>)
   In file included from fs/btrfs/raid56.c:8:
   In function 'raid56_alloc_missing_rbio':
>> include/linux/bio.h:563:35: warning: dereference of NULL '((struct bio_list 
>> *)rbio)[8].tail' [CWE-476] [-Wanalyzer-null-dereference]
     563 |                 bl->tail->bi_next = bio;
         |                 ~~~~~~~~~~~~~~~~~~^~~~~
     'raid56_alloc_missing_rbio': events 1-2
       |
       |fs/btrfs/raid56.c:2800:1:
       | 2800 | raid56_alloc_missing_rbio(struct bio *bio, struct 
btrfs_io_context *bioc,
       |      | ^~~~~~~~~~~~~~~~~~~~~~~~~
       |      | |
       |      | (1) entry to 'raid56_alloc_missing_rbio'
       |......
       | 2806 |         rbio = alloc_rbio(fs_info, bioc, length);
       |      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                |
       |      |                (2) calling 'alloc_rbio' from 
'raid56_alloc_missing_rbio'
       |
       +--> 'alloc_rbio': events 3-4
              |
              | 1025 | static struct btrfs_raid_bio *alloc_rbio(struct 
btrfs_fs_info *fs_info,
              |      |                               ^~~~~~~~~~
              |      |                               |
              |      |                               (3) entry to 'alloc_rbio'
              |......
              | 1050 |         if (!rbio)
              |      |            ~                   
              |      |            |
              |      |            (4) following 'false' branch (when 'rbio' is 
non-NULL)...
              |
            'alloc_rbio': event 5
              |
              |include/linux/bio.h:539:29:
              |  539 |         bl->head = bl->tail = NULL;
              |
            'alloc_rbio': event 6
              |
              |  539 |         bl->head = bl->tail = NULL;
              |
            'alloc_rbio': event 7
              |
              |  539 |         bl->head = bl->tail = NULL;
              |
            'alloc_rbio': event 8
              |
              |  539 |         bl->head = bl->tail = NULL;
              |
       <------+
       |
     'raid56_alloc_missing_rbio': events 9-11
       |
       |fs/btrfs/raid56.c:2806:16:
       | 2806 |         rbio = alloc_rbio(fs_info, bioc, length);
       |      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                |
       |      |                (9) returning to 'raid56_alloc_missing_rbio' 
from 'alloc_rbio'
       | 2807 |         if (IS_ERR(rbio))
       |      |            ~    
       |      |            |
       |      |            (10) following 'false' branch...
       |......
       | 2810 |         rbio->operation = BTRFS_RBIO_REBUILD_MISSING;
       |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                         |
       |      |                         (11) ...to here
       |
     'raid56_alloc_missing_rbio': events 12-14
       |
       |include/linux/bio.h:562:12:
       |  562 |         if (bl->tail)
       |      |            ^
       |      |            |
       |      |            (12) following 'true' branch...
       |  563 |                 bl->tail->bi_next = bio;
       |      |                 ~~~~~~~~~~~~~~~~~~~~~~~
       |      |                                   |
       |      |                                   (13) ...to here
       |      |                                   (14) dereference of NULL 
'((struct bio_list *)rbio)[8].tail'
       |

vim +563 include/linux/bio.h

8f3d8ba20e6799 Christoph Hellwig 2009-04-07  557  
8f3d8ba20e6799 Christoph Hellwig 2009-04-07  558  static inline void 
bio_list_add(struct bio_list *bl, struct bio *bio)
8f3d8ba20e6799 Christoph Hellwig 2009-04-07  559  {
8f3d8ba20e6799 Christoph Hellwig 2009-04-07  560        bio->bi_next = NULL;
8f3d8ba20e6799 Christoph Hellwig 2009-04-07  561  
8f3d8ba20e6799 Christoph Hellwig 2009-04-07  562        if (bl->tail)
8f3d8ba20e6799 Christoph Hellwig 2009-04-07 @563                
bl->tail->bi_next = bio;
8f3d8ba20e6799 Christoph Hellwig 2009-04-07  564        else
8f3d8ba20e6799 Christoph Hellwig 2009-04-07  565                bl->head = bio;
8f3d8ba20e6799 Christoph Hellwig 2009-04-07  566  
8f3d8ba20e6799 Christoph Hellwig 2009-04-07  567        bl->tail = bio;
8f3d8ba20e6799 Christoph Hellwig 2009-04-07  568  }
8f3d8ba20e6799 Christoph Hellwig 2009-04-07  569  

:::::: The code at line 563 was first introduced by commit
:::::: 8f3d8ba20e67991b531e9c0227dcd1f99271a32c block: move bio list helpers 
into bio.h

:::::: TO: Christoph Hellwig <[email protected]>
:::::: CC: Jens Axboe <[email protected]>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to