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, 4 May 2023 13:05:27 +0300
From:   Dan Carpenter <dan.carpenter@...aro.org>
To:     oe-kbuild@...ts.linux.dev, Samuel Holland <samuel@...lland.org>
Cc:     lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
        linux-kernel@...r.kernel.org,
        Jernej Skrabec <jernej.skrabec@...il.com>
Subject: drivers/bus/sunxi-rsb.c:286 _sunxi_rsb_run_xfer() warn: assigning
 (-110) to unsigned variable 'timeout'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   1a5304fecee523060f26e2778d9d8e33c0562df3
commit: 077686da0e2162c4ea5ae0df205849c2a7a84479 bus: sunxi-rsb: Support atomic transfers
config: arm64-randconfig-m041-20230428 (https://download.01.org/0day-ci/archive/20230504/202305041714.yy6fC4eJ-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
| Reported-by: Dan Carpenter <error27@...il.com>
| Link: https://lore.kernel.org/r/202305041714.yy6fC4eJ-lkp@intel.com/

smatch warnings:
drivers/bus/sunxi-rsb.c:286 _sunxi_rsb_run_xfer() warn: assigning (-110) to unsigned variable 'timeout'

vim +/timeout +286 drivers/bus/sunxi-rsb.c

d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  268  static int _sunxi_rsb_run_xfer(struct sunxi_rsb *rsb)
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  269  {
077686da0e2162 Samuel Holland 2022-11-13  270  	u32 int_mask, status;
077686da0e2162 Samuel Holland 2022-11-13  271  	bool timeout;
077686da0e2162 Samuel Holland 2022-11-13  272  
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  273  	if (readl(rsb->regs + RSB_CTRL) & RSB_CTRL_START_TRANS) {
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  274  		dev_dbg(rsb->dev, "RSB transfer still in progress\n");
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  275  		return -EBUSY;
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  276  	}
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  277  
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  278  	reinit_completion(&rsb->complete);
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  279  
077686da0e2162 Samuel Holland 2022-11-13  280  	int_mask = RSB_INTS_LOAD_BSY | RSB_INTS_TRANS_ERR | RSB_INTS_TRANS_OVER;
077686da0e2162 Samuel Holland 2022-11-13  281  	writel(int_mask, rsb->regs + RSB_INTE);
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  282  	writel(RSB_CTRL_START_TRANS | RSB_CTRL_GLOBAL_INT_ENB,
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  283  	       rsb->regs + RSB_CTRL);
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  284  
077686da0e2162 Samuel Holland 2022-11-13  285  	if (irqs_disabled()) {
077686da0e2162 Samuel Holland 2022-11-13 @286  		timeout = readl_poll_timeout_atomic(rsb->regs + RSB_INTS,
077686da0e2162 Samuel Holland 2022-11-13  287  						    status, (status & int_mask),
077686da0e2162 Samuel Holland 2022-11-13  288  						    10, 100000);

This works, but Smatch doesn't like it when people save negatives to
a bool.

077686da0e2162 Samuel Holland 2022-11-13  289  		writel(status, rsb->regs + RSB_INTS);
077686da0e2162 Samuel Holland 2022-11-13  290  	} else {
077686da0e2162 Samuel Holland 2022-11-13  291  		timeout = !wait_for_completion_io_timeout(&rsb->complete,
077686da0e2162 Samuel Holland 2022-11-13  292  							  msecs_to_jiffies(100));
077686da0e2162 Samuel Holland 2022-11-13  293  		status = rsb->status;
077686da0e2162 Samuel Holland 2022-11-13  294  	}
077686da0e2162 Samuel Holland 2022-11-13  295  
077686da0e2162 Samuel Holland 2022-11-13  296  	if (timeout) {
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  297  		dev_dbg(rsb->dev, "RSB timeout\n");
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  298  
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  299  		/* abort the transfer */
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  300  		writel(RSB_CTRL_ABORT_TRANS, rsb->regs + RSB_CTRL);
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  301  
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  302  		/* clear any interrupt flags */
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  303  		writel(readl(rsb->regs + RSB_INTS), rsb->regs + RSB_INTS);
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  304  
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  305  		return -ETIMEDOUT;
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  306  	}
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  307  
077686da0e2162 Samuel Holland 2022-11-13  308  	if (status & RSB_INTS_LOAD_BSY) {
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  309  		dev_dbg(rsb->dev, "RSB busy\n");
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  310  		return -EBUSY;
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  311  	}
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  312  
077686da0e2162 Samuel Holland 2022-11-13  313  	if (status & RSB_INTS_TRANS_ERR) {
077686da0e2162 Samuel Holland 2022-11-13  314  		if (status & RSB_INTS_TRANS_ERR_ACK) {
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  315  			dev_dbg(rsb->dev, "RSB slave nack\n");
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  316  			return -EINVAL;
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  317  		}
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  318  
077686da0e2162 Samuel Holland 2022-11-13  319  		if (status & RSB_INTS_TRANS_ERR_DATA) {
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  320  			dev_dbg(rsb->dev, "RSB transfer data error\n");
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  321  			return -EIO;
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  322  		}
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  323  	}
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  324  
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  325  	return 0;
d787dcdb9c8f41 Chen-Yu Tsai   2015-10-23  326  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ