[linux-next:master 5319/5462] drivers/media/rc/lirc_dev.c:368:2: warning: 'txbuf' may be used uninitialized in this function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   a5791b188fb25ff731d01d1c463b01a99c58f930
commit: d60ea519eb2fbee045ca18a26bd37d5949ac4f87 [5319/5462] Merge remote-tracking branch 'v4l-dvb/master'
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout d60ea519eb2fbee045ca18a26bd37d5949ac4f87
        # save the attached .config to linux build tree
        make.cross ARCH=xtensa 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   drivers/media/rc/lirc_dev.c: In function 'ir_lirc_transmit_ir':
>> drivers/media/rc/lirc_dev.c:368:2: warning: 'txbuf' may be used uninitialized in this function [-Wmaybe-uninitialized]
     kfree(txbuf);
     ^~~~~~~~~~~~

vim +/txbuf +368 drivers/media/rc/lirc_dev.c

74c839b2f drivers/media/rc/lirc_dev.c Sean Young          2017-01-30  228  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  229  static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf,
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  230  				   size_t n, loff_t *ppos)
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  231  {
7e45d660e drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  232  	struct lirc_fh *fh = file->private_data;
7e45d660e drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  233  	struct rc_dev *dev = fh->rc;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  234  	unsigned int *txbuf;
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  235  	struct ir_raw_event *raw = NULL;
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  236  	ssize_t ret;
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  237  	size_t count;
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  238  	ktime_t start;
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  239  	s64 towait;
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  240  	unsigned int duration = 0; /* signal duration in us */
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  241  	int i;
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  242  
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  243  	ret = mutex_lock_interruptible(&dev->lock);
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  244  	if (ret)
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  245  		return ret;
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  246  
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  247  	if (!dev->registered) {
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  248  		ret = -ENODEV;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  249  		goto out_unlock;
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  250  	}
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  251  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  252  	start = ktime_get();
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  253  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  254  	if (!dev->tx_ir) {
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  255  		ret = -EINVAL;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  256  		goto out_unlock;
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  257  	}
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  258  
7e45d660e drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  259  	if (fh->send_mode == LIRC_MODE_SCANCODE) {
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  260  		struct lirc_scancode scan;
3381b779a drivers/media/rc/lirc_dev.c David Härdeman      2017-06-30  261  
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  262  		if (n != sizeof(scan)) {
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  263  			ret = -EINVAL;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  264  			goto out_unlock;
3381b779a drivers/media/rc/lirc_dev.c David Härdeman      2017-06-30  265  		}
3381b779a drivers/media/rc/lirc_dev.c David Härdeman      2017-06-30  266  
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  267  		if (copy_from_user(&scan, buf, sizeof(scan))) {
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  268  			ret = -EFAULT;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  269  			goto out_unlock;
3381b779a drivers/media/rc/lirc_dev.c David Härdeman      2017-06-30  270  		}
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  271  
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  272  		if (scan.flags || scan.keycode || scan.timestamp) {
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  273  			ret = -EINVAL;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  274  			goto out_unlock;
ca7a722db drivers/media/rc/lirc_dev.c Srinivas Kandagatla 2013-07-22  275  		}
ca7a722db drivers/media/rc/lirc_dev.c Srinivas Kandagatla 2013-07-22  276  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  277  		/*
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  278  		 * The scancode field in lirc_scancode is 64-bit simply
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  279  		 * to future-proof it, since there are IR protocols encode
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  280  		 * use more than 32 bits. For now only 32-bit protocols
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  281  		 * are supported.
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  282  		 */
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  283  		if (scan.scancode > U32_MAX ||
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  284  		    !rc_validate_scancode(scan.rc_proto, scan.scancode)) {
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  285  			ret = -EINVAL;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  286  			goto out_unlock;
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  287  		}
2c5a1f446 drivers/media/rc/lirc_dev.c David Härdeman      2017-05-01  288  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  289  		raw = kmalloc_array(LIRCBUF_SIZE, sizeof(*raw), GFP_KERNEL);
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  290  		if (!raw) {
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  291  			ret = -ENOMEM;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  292  			goto out_unlock;
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  293  		}
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  294  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  295  		ret = ir_raw_encode_scancode(scan.rc_proto, scan.scancode,
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  296  					     raw, LIRCBUF_SIZE);
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  297  		if (ret < 0)
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  298  			goto out_kfree;
d9d2e9d5c drivers/media/IR/lirc_dev.c Arnd Bergmann       2010-08-15  299  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  300  		count = ret;
3381b779a drivers/media/rc/lirc_dev.c David Härdeman      2017-06-30  301  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  302  		txbuf = kmalloc_array(count, sizeof(unsigned int), GFP_KERNEL);
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  303  		if (!txbuf) {
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  304  			ret = -ENOMEM;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  305  			goto out_kfree;
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  306  		}
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  307  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  308  		for (i = 0; i < count; i++)
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  309  			/* Convert from NS to US */
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  310  			txbuf[i] = DIV_ROUND_UP(raw[i].duration, 1000);
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  311  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  312  		if (dev->s_tx_carrier) {
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  313  			int carrier = ir_raw_encode_carrier(scan.rc_proto);
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  314  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  315  			if (carrier > 0)
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  316  				dev->s_tx_carrier(dev, carrier);
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  317  		}
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  318  	} else {
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  319  		if (n < sizeof(unsigned int) || n % sizeof(unsigned int)) {
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  320  			ret = -EINVAL;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  321  			goto out_unlock;
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  322  		}
3381b779a drivers/media/rc/lirc_dev.c David Härdeman      2017-06-30  323  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  324  		count = n / sizeof(unsigned int);
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  325  		if (count > LIRCBUF_SIZE || count % 2 == 0) {
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  326  			ret = -EINVAL;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  327  			goto out_unlock;
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  328  		}
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  329  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  330  		txbuf = memdup_user(buf, n);
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  331  		if (IS_ERR(txbuf)) {
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  332  			ret = PTR_ERR(txbuf);
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  333  			goto out_unlock;
4957133fe drivers/media/rc/lirc_dev.c Sean Young          2017-11-04  334  		}
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  335  	}
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  336  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  337  	for (i = 0; i < count; i++) {
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  338  		if (txbuf[i] > IR_MAX_DURATION / 1000 - duration || !txbuf[i]) {
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  339  			ret = -EINVAL;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  340  			goto out_kfree;
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  341  		}
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  342  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  343  		duration += txbuf[i];
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  344  	}
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  345  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  346  	ret = dev->tx_ir(dev, txbuf, count);
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  347  	if (ret < 0)
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  348  		goto out_kfree;
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  349  
f81a8158d drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  350  	kfree(txbuf);
f81a8158d drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  351  	kfree(raw);
f81a8158d drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  352  	mutex_unlock(&dev->lock);
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  353  
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  354  	/*
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  355  	 * The lircd gap calculation expects the write function to
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  356  	 * wait for the actual IR signal to be transmitted before
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  357  	 * returning.
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  358  	 */
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  359  	towait = ktime_us_delta(ktime_add_us(start, duration),
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  360  				ktime_get());
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  361  	if (towait > 0) {
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  362  		set_current_state(TASK_INTERRUPTIBLE);
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  363  		schedule_timeout(usecs_to_jiffies(towait));
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  364  	}
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  365  
f81a8158d drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  366  	return n;
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  367  out_kfree:
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02 @368  	kfree(txbuf);
42e0442f8 drivers/media/rc/lirc_dev.c Sean Young          2017-11-02  369  	kfree(raw);
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  370  out_unlock:
a74b2bff5 drivers/media/rc/lirc_dev.c Sean Young          2017-12-13  371  	mutex_unlock(&dev->lock);
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  372  	return ret;
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  373  }
4a62a5ab5 drivers/media/IR/lirc_dev.c Jarod Wilson        2010-07-03  374  

:::::: The code at line 368 was first introduced by commit
:::::: 42e0442f8a237d3de9ea3f2dd2be2739e6db7fdb media: rc: move ir-lirc-codec.c contents into lirc_dev.c

:::::: TO: Sean Young <sean@xxxxxxxx>
:::::: CC: Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxxxxx>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux