All of lore.kernel.org
 help / color / mirror / Atom feed
* [hch-block:blkdev_get 11/20] drivers/md/md.c:5694:8: warning: variable 'error' is used uninitialized whenever 'if' condition is true
@ 2021-03-03 21:40 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-03-03 21:40 UTC (permalink / raw)
  To: kbuild-all

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

tree:   git://git.infradead.org/users/hch/block.git blkdev_get
head:   e23f079069b8993ed92b22dabbe067090baadfbe
commit: e338d98c9c7725f1ba2404e946971e506b27cd63 [11/20] md: do not return existing mddevs from mddev_find_or_alloc
config: arm64-randconfig-r034-20210303 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a7cad6680b4087eff8994f1f99ac40c661a6621f)
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 arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        git remote add hch-block git://git.infradead.org/users/hch/block.git
        git fetch --no-tags hch-block blkdev_get
        git checkout e338d98c9c7725f1ba2404e946971e506b27cd63
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64 

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

All warnings (new ones prefixed by >>):

>> drivers/md/md.c:5694:8: warning: variable 'error' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
                           if (mddev2->gendisk &&
                               ^~~~~~~~~~~~~~~~~~
   drivers/md/md.c:5765:7: note: uninitialized use occurs here
           if (!error && mddev->kobj.sd) {
                ^~~~~
   drivers/md/md.c:5694:4: note: remove the 'if' if its condition is always false
                           if (mddev2->gendisk &&
                           ^~~~~~~~~~~~~~~~~~~~~~
   drivers/md/md.c:5668:11: note: initialize the variable 'error' to silence this warning
           int error;
                    ^
                     = 0
   1 warning generated.


vim +5694 drivers/md/md.c

a415c0f1062791 NeilBrown          2017-06-05  5650  
efeb53c0e57213 NeilBrown          2009-01-09  5651  static int md_alloc(dev_t dev, char *name)
^1da177e4c3f41 Linus Torvalds     2005-04-16  5652  {
039b7225e6e987 NeilBrown          2017-04-12  5653  	/*
039b7225e6e987 NeilBrown          2017-04-12  5654  	 * If dev is zero, name is the name of a device to allocate with
039b7225e6e987 NeilBrown          2017-04-12  5655  	 * an arbitrary minor number.  It will be "md_???"
039b7225e6e987 NeilBrown          2017-04-12  5656  	 * If dev is non-zero it must be a device number with a MAJOR of
039b7225e6e987 NeilBrown          2017-04-12  5657  	 * MD_MAJOR or mdp_major.  In this case, if "name" is NULL, then
039b7225e6e987 NeilBrown          2017-04-12  5658  	 * the device is being created by opening a node in /dev.
039b7225e6e987 NeilBrown          2017-04-12  5659  	 * If "name" is not NULL, the device is being created by
039b7225e6e987 NeilBrown          2017-04-12  5660  	 * writing to /sys/module/md_mod/parameters/new_array.
039b7225e6e987 NeilBrown          2017-04-12  5661  	 */
48c9c27b8bcd2a Arjan van de Ven   2006-03-27  5662  	static DEFINE_MUTEX(disks_mutex);
e338d98c9c7725 Christoph Hellwig  2021-03-03  5663  	struct mddev *mddev;
^1da177e4c3f41 Linus Torvalds     2005-04-16  5664  	struct gendisk *disk;
efeb53c0e57213 NeilBrown          2009-01-09  5665  	int partitioned;
efeb53c0e57213 NeilBrown          2009-01-09  5666  	int shift;
efeb53c0e57213 NeilBrown          2009-01-09  5667  	int unit;
3830c62fef49f8 Greg Kroah-Hartman 2007-12-17  5668  	int error;
^1da177e4c3f41 Linus Torvalds     2005-04-16  5669  
e338d98c9c7725 Christoph Hellwig  2021-03-03  5670  	/*
e338d98c9c7725 Christoph Hellwig  2021-03-03  5671  	 * Wait for any previous instance of this device to be completely
e338d98c9c7725 Christoph Hellwig  2021-03-03  5672  	 * removed (mddev_delayed_delete).
d3374825ce57ba NeilBrown          2009-01-09  5673  	 */
e804ac780e2f01 Tejun Heo          2010-10-15  5674  	flush_workqueue(md_misc_wq);
d3374825ce57ba NeilBrown          2009-01-09  5675  
48c9c27b8bcd2a Arjan van de Ven   2006-03-27  5676  	mutex_lock(&disks_mutex);
e338d98c9c7725 Christoph Hellwig  2021-03-03  5677  	mddev = mddev_alloc(dev);
e338d98c9c7725 Christoph Hellwig  2021-03-03  5678  	if (IS_ERR(mddev)) {
e338d98c9c7725 Christoph Hellwig  2021-03-03  5679  		mutex_unlock(&disks_mutex);
e338d98c9c7725 Christoph Hellwig  2021-03-03  5680  		return PTR_ERR(mddev);
e338d98c9c7725 Christoph Hellwig  2021-03-03  5681  	}
e338d98c9c7725 Christoph Hellwig  2021-03-03  5682  
e338d98c9c7725 Christoph Hellwig  2021-03-03  5683  	partitioned = (MAJOR(mddev->unit) != MD_MAJOR);
e338d98c9c7725 Christoph Hellwig  2021-03-03  5684  	shift = partitioned ? MdpMinorShift : 0;
e338d98c9c7725 Christoph Hellwig  2021-03-03  5685  	unit = MINOR(mddev->unit) >> shift;
efeb53c0e57213 NeilBrown          2009-01-09  5686  
039b7225e6e987 NeilBrown          2017-04-12  5687  	if (name && !dev) {
efeb53c0e57213 NeilBrown          2009-01-09  5688  		/* Need to ensure that 'name' is not a duplicate.
efeb53c0e57213 NeilBrown          2009-01-09  5689  		 */
fd01b88c75a718 NeilBrown          2011-10-11  5690  		struct mddev *mddev2;
efeb53c0e57213 NeilBrown          2009-01-09  5691  		spin_lock(&all_mddevs_lock);
efeb53c0e57213 NeilBrown          2009-01-09  5692  
efeb53c0e57213 NeilBrown          2009-01-09  5693  		list_for_each_entry(mddev2, &all_mddevs, all_mddevs)
efeb53c0e57213 NeilBrown          2009-01-09 @5694  			if (mddev2->gendisk &&
efeb53c0e57213 NeilBrown          2009-01-09  5695  			    strcmp(mddev2->gendisk->disk_name, name) == 0) {
efeb53c0e57213 NeilBrown          2009-01-09  5696  				spin_unlock(&all_mddevs_lock);
0909dc448c98ed NeilBrown          2009-07-01  5697  				goto abort;
efeb53c0e57213 NeilBrown          2009-01-09  5698  			}
efeb53c0e57213 NeilBrown          2009-01-09  5699  		spin_unlock(&all_mddevs_lock);
^1da177e4c3f41 Linus Torvalds     2005-04-16  5700  	}
039b7225e6e987 NeilBrown          2017-04-12  5701  	if (name && dev)
039b7225e6e987 NeilBrown          2017-04-12  5702  		/*
039b7225e6e987 NeilBrown          2017-04-12  5703  		 * Creating /dev/mdNNN via "newarray", so adjust hold_active.
039b7225e6e987 NeilBrown          2017-04-12  5704  		 */
039b7225e6e987 NeilBrown          2017-04-12  5705  		mddev->hold_active = UNTIL_STOP;
8b76539823d715 NeilBrown          2009-01-09  5706  
41d2d848e5c092 Artur Paszkiewicz  2020-07-03  5707  	error = mempool_init_kmalloc_pool(&mddev->md_io_pool, BIO_POOL_SIZE,
41d2d848e5c092 Artur Paszkiewicz  2020-07-03  5708  					  sizeof(struct md_io));
41d2d848e5c092 Artur Paszkiewicz  2020-07-03  5709  	if (error)
41d2d848e5c092 Artur Paszkiewicz  2020-07-03  5710  		goto abort;
41d2d848e5c092 Artur Paszkiewicz  2020-07-03  5711  
0909dc448c98ed NeilBrown          2009-07-01  5712  	error = -ENOMEM;
c62b37d96b6eb3 Christoph Hellwig  2020-07-01  5713  	mddev->queue = blk_alloc_queue(NUMA_NO_NODE);
0909dc448c98ed NeilBrown          2009-07-01  5714  	if (!mddev->queue)
0909dc448c98ed NeilBrown          2009-07-01  5715  		goto abort;
409c57f3801701 NeilBrown          2009-03-31  5716  
b1bd055d397e09 Martin K. Petersen 2012-01-11  5717  	blk_set_stacking_limits(&mddev->queue->limits);
8b76539823d715 NeilBrown          2009-01-09  5718  
^1da177e4c3f41 Linus Torvalds     2005-04-16  5719  	disk = alloc_disk(1 << shift);
^1da177e4c3f41 Linus Torvalds     2005-04-16  5720  	if (!disk) {
8b76539823d715 NeilBrown          2009-01-09  5721  		blk_cleanup_queue(mddev->queue);
8b76539823d715 NeilBrown          2009-01-09  5722  		mddev->queue = NULL;
0909dc448c98ed NeilBrown          2009-07-01  5723  		goto abort;
^1da177e4c3f41 Linus Torvalds     2005-04-16  5724  	}
efeb53c0e57213 NeilBrown          2009-01-09  5725  	disk->major = MAJOR(mddev->unit);
^1da177e4c3f41 Linus Torvalds     2005-04-16  5726  	disk->first_minor = unit << shift;
efeb53c0e57213 NeilBrown          2009-01-09  5727  	if (name)
efeb53c0e57213 NeilBrown          2009-01-09  5728  		strcpy(disk->disk_name, name);
efeb53c0e57213 NeilBrown          2009-01-09  5729  	else if (partitioned)
^1da177e4c3f41 Linus Torvalds     2005-04-16  5730  		sprintf(disk->disk_name, "md_d%d", unit);
ce7b0f46bbf4bf Greg Kroah-Hartman 2005-06-20  5731  	else
^1da177e4c3f41 Linus Torvalds     2005-04-16  5732  		sprintf(disk->disk_name, "md%d", unit);
^1da177e4c3f41 Linus Torvalds     2005-04-16  5733  	disk->fops = &md_fops;
^1da177e4c3f41 Linus Torvalds     2005-04-16  5734  	disk->private_data = mddev;
^1da177e4c3f41 Linus Torvalds     2005-04-16  5735  	disk->queue = mddev->queue;
56883a7ec85f5b Jens Axboe         2016-03-30  5736  	blk_queue_write_cache(mddev->queue, true, true);
92850bbd712287 NeilBrown          2008-10-21  5737  	/* Allow extended partitions.  This makes the
d3374825ce57ba NeilBrown          2009-01-09  5738  	 * 'mdp' device redundant, but we can't really
92850bbd712287 NeilBrown          2008-10-21  5739  	 * remove it now.
92850bbd712287 NeilBrown          2008-10-21  5740  	 */
92850bbd712287 NeilBrown          2008-10-21  5741  	disk->flags |= GENHD_FL_EXT_DEVT;
a564e23f0f9975 Christoph Hellwig  2020-07-08  5742  	disk->events |= DISK_EVENT_MEDIA_CHANGE;
^1da177e4c3f41 Linus Torvalds     2005-04-16  5743  	mddev->gendisk = disk;
b0140891a8cea3 NeilBrown          2011-05-10  5744  	/* As soon as we call add_disk(), another thread could get
b0140891a8cea3 NeilBrown          2011-05-10  5745  	 * through to md_open, so make sure it doesn't get too far
b0140891a8cea3 NeilBrown          2011-05-10  5746  	 */
b0140891a8cea3 NeilBrown          2011-05-10  5747  	mutex_lock(&mddev->open_mutex);
b0140891a8cea3 NeilBrown          2011-05-10  5748  	add_disk(disk);
b0140891a8cea3 NeilBrown          2011-05-10  5749  
28dec870aaf704 Kent Overstreet    2018-06-07  5750  	error = kobject_add(&mddev->kobj, &disk_to_dev(disk)->kobj, "%s", "md");
0909dc448c98ed NeilBrown          2009-07-01  5751  	if (error) {
0909dc448c98ed NeilBrown          2009-07-01  5752  		/* This isn't possible, but as kobject_init_and_add is marked
0909dc448c98ed NeilBrown          2009-07-01  5753  		 * __must_check, we must do something with the result
0909dc448c98ed NeilBrown          2009-07-01  5754  		 */
9d48739ef19aa8 NeilBrown          2016-11-02  5755  		pr_debug("md: cannot register %s/md - name in use\n",
5e55e2f5fc95b3 NeilBrown          2007-03-26  5756  			 disk->disk_name);
0909dc448c98ed NeilBrown          2009-07-01  5757  		error = 0;
0909dc448c98ed NeilBrown          2009-07-01  5758  	}
00bcb4ac7ee7e5 NeilBrown          2010-06-01  5759  	if (mddev->kobj.sd &&
00bcb4ac7ee7e5 NeilBrown          2010-06-01  5760  	    sysfs_create_group(&mddev->kobj, &md_bitmap_group))
9d48739ef19aa8 NeilBrown          2016-11-02  5761  		pr_debug("pointless warning\n");
b0140891a8cea3 NeilBrown          2011-05-10  5762  	mutex_unlock(&mddev->open_mutex);
0909dc448c98ed NeilBrown          2009-07-01  5763   abort:
0909dc448c98ed NeilBrown          2009-07-01  5764  	mutex_unlock(&disks_mutex);
00bcb4ac7ee7e5 NeilBrown          2010-06-01  5765  	if (!error && mddev->kobj.sd) {
3830c62fef49f8 Greg Kroah-Hartman 2007-12-17  5766  		kobject_uevent(&mddev->kobj, KOBJ_ADD);
00bcb4ac7ee7e5 NeilBrown          2010-06-01  5767  		mddev->sysfs_state = sysfs_get_dirent_safe(mddev->kobj.sd, "array_state");
e1a86dbbbd6a77 Junxiao Bi         2020-07-14  5768  		mddev->sysfs_level = sysfs_get_dirent_safe(mddev->kobj.sd, "level");
b62b75905d571c NeilBrown          2008-10-21  5769  	}
d3374825ce57ba NeilBrown          2009-01-09  5770  	mddev_put(mddev);
0909dc448c98ed NeilBrown          2009-07-01  5771  	return error;
efeb53c0e57213 NeilBrown          2009-01-09  5772  }
efeb53c0e57213 NeilBrown          2009-01-09  5773  

:::::: The code at line 5694 was first introduced by commit
:::::: efeb53c0e57213e843b7ef3cc6ebcdea7d6186ac md: Allow md devices to be created by name.

:::::: TO: NeilBrown <neilb@suse.de>
:::::: CC: NeilBrown <neilb@suse.de>

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

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-03 21:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 21:40 [hch-block:blkdev_get 11/20] drivers/md/md.c:5694:8: warning: variable 'error' is used uninitialized whenever 'if' condition is true kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.