CC: kbuild-...@lists.01.org
In-Reply-To: <20210122162529.84978-13-alexandru.ardel...@analog.com>
References: <20210122162529.84978-13-alexandru.ardel...@analog.com>
TO: Alexandru Ardelean <alexandru.ardel...@analog.com>
TO: linux-ker...@vger.kernel.org
TO: linux-...@vger.kernel.org
CC: l...@metafoo.de
CC: michael.henner...@analog.com
CC: ji...@kernel.org
CC: nuno...@analog.com
CC: dragos.bog...@analog.com
CC: Alexandru Ardelean <alexandru.ardel...@analog.com>

Hi Alexandru,

I love your patch! Perhaps something to improve:

[auto build test WARNING on iio/togreg]
[also build test WARNING on linux/master linus/master v5.11-rc5 next-20210122]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    
https://github.com/0day-ci/linux/commits/Alexandru-Ardelean/iio-core-buffer-add-support-for-multiple-IIO-buffers-per-IIO-device/20210125-053419
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
:::::: branch date: 11 hours ago
:::::: commit date: 11 hours ago
config: i386-randconfig-m021-20210125 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-20) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>
Reported-by: Dan Carpenter <dan.carpen...@oracle.com>

New smatch warnings:
drivers/iio/industrialio-buffer.c:1451 iio_device_buffer_getfd() warn: 
potential spectre issue 'iio_dev_opaque->attached_buffers' [r] (local cap)
drivers/iio/industrialio-buffer.c:1453 iio_device_buffer_getfd() warn: possible 
spectre second half.  'buffer'

Old smatch warnings:
drivers/iio/industrialio-buffer.c:1721 iio_buffer_alloc_sysfs_and_mask() error: 
uninitialized symbol 'cnt'.

vim +1451 drivers/iio/industrialio-buffer.c

2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1424  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1425  static long 
iio_device_buffer_getfd(struct iio_dev *indio_dev, unsigned long arg)
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1426  {
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1427    struct iio_dev_opaque 
*iio_dev_opaque = to_iio_dev_opaque(indio_dev);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1428    int __user *ival = (int 
__user *)arg;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1429    char 
buf_name[sizeof("iio:buffer:xxx")];
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1430    struct 
iio_dev_buffer_pair *ib;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1431    struct iio_buffer 
*buffer;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1432    int fd, idx;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1433  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1434    if 
(copy_from_user(&idx, ival, sizeof(idx)))
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1435            return -EFAULT;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1436  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1437    if (idx == 0) {
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1438            fd = 0;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1439            if 
(copy_to_user(ival, &fd, sizeof(fd)))
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1440                    return 
-EFAULT;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1441            return 0;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1442    }
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1443  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1444    if (idx >= 
iio_dev_opaque->attached_buffers_cnt)
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1445            return -ENOENT;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1446  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1447    fd = 
mutex_lock_interruptible(&indio_dev->mlock);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1448    if (fd)
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1449            return fd;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1450  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22 @1451    buffer = 
iio_dev_opaque->attached_buffers[idx];
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1452  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22 @1453    if 
(test_and_set_bit(IIO_BUSY_BIT_POS, &buffer->flags)) {
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1454            fd = -EBUSY;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1455            goto 
error_unlock;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1456    }
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1457  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1458    
iio_device_get(indio_dev);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1459  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1460    ib = 
kzalloc(sizeof(*ib), GFP_KERNEL);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1461    if (!ib) {
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1462            fd = -ENOMEM;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1463            goto 
error_iio_dev_put;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1464    }
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1465  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1466    ib->indio_dev = 
indio_dev;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1467    ib->buffer = buffer;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1468  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1469    fd = 
anon_inode_getfd(buf_name, &iio_buffer_chrdev_fileops,
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1470                          
ib, O_RDWR | O_CLOEXEC);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1471    if (fd < 0)
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1472            goto 
error_free_ib;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1473  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1474    if (copy_to_user(ival, 
&fd, sizeof(fd))) {
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1475            fd = -EFAULT;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1476            goto 
error_free_ib;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1477    }
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1478  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1479    
mutex_unlock(&indio_dev->mlock);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1480    return fd;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1481  
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1482  error_free_ib:
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1483    kfree(ib);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1484  error_iio_dev_put:
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1485    
iio_device_put(indio_dev);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1486    
clear_bit(IIO_BUSY_BIT_POS, &buffer->flags);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1487  error_unlock:
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1488    
mutex_unlock(&indio_dev->mlock);
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1489    return fd;
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1490  }
2bcbc1e1334fb555 Alexandru Ardelean 2021-01-22  1491  

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

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to