lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Thu, 13 Aug 2020 11:24:57 +0800
From:   kernel test robot <lkp@...el.com>
To:     Heinz Mauelshagen <heinzm@...hat.com>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        Mike Snitzer <snitzer@...hat.com>,
        Damien Le Moal <DamienLeMoal@....com>,
        Randy Dunlap <rdunlap@...radead.org>
Subject: drivers/md/dm-ebs-target.c:264:4: warning: Variable 'r' is
 reassigned a value before the old one has been used.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   dc06fe51d26efc100ac74121607c01a454867c91
commit: d3c7b35c20d60650bac8b55c17b194adda03a979 dm: add emulated block size target
date:   3 months ago
compiler: sparc-linux-gcc (GCC) 9.3.0

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


cppcheck warnings: (new ones prefixed by >>)

>> drivers/md/dm-ebs-target.c:264:4: warning: Variable 'r' is reassigned a value before the old one has been used. [redundantAssignment]
    r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &ec->dev);
      ^
   drivers/md/dm-ebs-target.c:237:4: note: Variable 'r' is reassigned a value before the old one has been used.
    r = -EINVAL;
      ^
   drivers/md/dm-ebs-target.c:264:4: note: Variable 'r' is reassigned a value before the old one has been used.
    r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &ec->dev);
      ^

vim +/r +264 drivers/md/dm-ebs-target.c

   208	
   209	/*
   210	 * Construct an emulated block size mapping: <dev_path> <offset> <ebs> [<ubs>]
   211	 *
   212	 * <dev_path>: path of the underlying device
   213	 * <offset>: offset in 512 bytes sectors into <dev_path>
   214	 * <ebs>: emulated block size in units of 512 bytes exposed to the upper layer
   215	 * [<ubs>]: underlying block size in units of 512 bytes imposed on the lower layer;
   216	 * 	    optional, if not supplied, retrieve logical block size from underlying device
   217	 */
   218	static int ebs_ctr(struct dm_target *ti, unsigned int argc, char **argv)
   219	{
   220		int r;
   221		unsigned short tmp1;
   222		unsigned long long tmp;
   223		char dummy;
   224		struct ebs_c *ec;
   225	
   226		if (argc < 3 || argc > 4) {
   227			ti->error = "Invalid argument count";
   228			return -EINVAL;
   229		}
   230	
   231		ec = ti->private = kzalloc(sizeof(*ec), GFP_KERNEL);
   232		if (!ec) {
   233			ti->error = "Cannot allocate ebs context";
   234			return -ENOMEM;
   235		}
   236	
   237		r = -EINVAL;
   238		if (sscanf(argv[1], "%llu%c", &tmp, &dummy) != 1 ||
   239		    tmp != (sector_t)tmp ||
   240		    (sector_t)tmp >= ti->len) {
   241			ti->error = "Invalid device offset sector";
   242			goto bad;
   243		}
   244		ec->start = tmp;
   245	
   246		if (sscanf(argv[2], "%hu%c", &tmp1, &dummy) != 1 ||
   247		    !__ebs_check_bs(tmp1) ||
   248		    to_bytes(tmp1) > PAGE_SIZE) {
   249			ti->error = "Invalid emulated block size";
   250			goto bad;
   251		}
   252		ec->e_bs = tmp1;
   253	
   254		if (argc > 3) {
   255			if (sscanf(argv[3], "%hu%c", &tmp1, &dummy) != 1 || !__ebs_check_bs(tmp1)) {
   256				ti->error = "Invalid underlying block size";
   257				goto bad;
   258			}
   259			ec->u_bs = tmp1;
   260			ec->u_bs_set = true;
   261		} else
   262			ec->u_bs_set = false;
   263	
 > 264		r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &ec->dev);
   265		if (r) {
   266			ti->error = "Device lookup failed";
   267			ec->dev = NULL;
   268			goto bad;
   269		}
   270	
   271		r = -EINVAL;
   272		if (!ec->u_bs_set) {
   273			ec->u_bs = to_sector(bdev_logical_block_size(ec->dev->bdev));
   274			if (!__ebs_check_bs(ec->u_bs)) {
   275				ti->error = "Invalid retrieved underlying block size";
   276				goto bad;
   277			}
   278		}
   279	
   280		if (!ec->u_bs_set && ec->e_bs == ec->u_bs)
   281			DMINFO("Emulation superfluous: emulated equal to underlying block size");
   282	
   283		if (__block_mod(ec->start, ec->u_bs)) {
   284			ti->error = "Device offset must be multiple of underlying block size";
   285			goto bad;
   286		}
   287	
   288		ec->bufio = dm_bufio_client_create(ec->dev->bdev, to_bytes(ec->u_bs), 1, 0, NULL, NULL);
   289		if (IS_ERR(ec->bufio)) {
   290			ti->error = "Cannot create dm bufio client";
   291			r = PTR_ERR(ec->bufio);
   292			ec->bufio = NULL;
   293			goto bad;
   294		}
   295	
   296		ec->wq = alloc_ordered_workqueue("dm-" DM_MSG_PREFIX, WQ_MEM_RECLAIM);
   297		if (!ec->wq) {
   298			ti->error = "Cannot create dm-" DM_MSG_PREFIX " workqueue";
   299			r = -ENOMEM;
   300			goto bad;
   301		}
   302	
   303		ec->block_shift = __ffs(ec->u_bs);
   304		INIT_WORK(&ec->ws, &__ebs_process_bios);
   305		bio_list_init(&ec->bios_in);
   306		spin_lock_init(&ec->lock);
   307	
   308		ti->num_flush_bios = 1;
   309		ti->num_discard_bios = 1;
   310		ti->num_secure_erase_bios = 0;
   311		ti->num_write_same_bios = 0;
   312		ti->num_write_zeroes_bios = 0;
   313		return 0;
   314	bad:
   315		ebs_dtr(ti);
   316		return r;
   317	}
   318	

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ