Re: [PATCH v3 06/11] iio: core: merge buffer/ & scan_elements/ attributes

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

 



Hi Alexandru,

url:    https://github.com/0day-ci/linux/commits/Alexandru-Ardelean/iio-core-buffer-add-support-for-multiple-IIO-buffers-per-IIO-device/20210201-233550
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: arc-randconfig-m031-20210201 (attached as .config)
compiler: arc-elf-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

New smatch warnings:
drivers/iio/industrialio-buffer.c:1413 __iio_buffer_alloc_sysfs_and_mask() error: uninitialized symbol 'ret'.

vim +/ret +1413 drivers/iio/industrialio-buffer.c

e16e0a778fec8a Alexandru Ardelean 2020-09-17  1314  static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
418ff389a5a48a Alexandru Ardelean 2021-02-01  1315  					     struct iio_dev *indio_dev,
418ff389a5a48a Alexandru Ardelean 2021-02-01  1316  					     int index)
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1317  {
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1318  	struct iio_dev_attr *p;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1319  	struct attribute **attr;
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1320  	int ret, i, attrn, scan_el_attrcount, buffer_attrcount;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1321  	const struct iio_chan_spec *channels;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1322  
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1323  	buffer_attrcount = 0;
08e7e0adaa1720 Lars-Peter Clausen 2014-11-26  1324  	if (buffer->attrs) {
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1325  		while (buffer->attrs[buffer_attrcount] != NULL)
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1326  			buffer_attrcount++;
08e7e0adaa1720 Lars-Peter Clausen 2014-11-26  1327  	}
08e7e0adaa1720 Lars-Peter Clausen 2014-11-26  1328  
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1329  	scan_el_attrcount = 0;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1330  	INIT_LIST_HEAD(&buffer->scan_el_dev_attr_list);
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1331  	channels = indio_dev->channels;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1332  	if (channels) {
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1333  		/* new magic */
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1334  		for (i = 0; i < indio_dev->num_channels; i++) {
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1335  			if (channels[i].scan_index < 0)
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1336  				continue;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1337  
ff3f7e049aef92 Alexandru Ardelean 2020-04-24  1338  			ret = iio_buffer_add_channel_sysfs(indio_dev, buffer,
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1339  							 &channels[i]);
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1340  			if (ret < 0)
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1341  				goto error_cleanup_dynamic;
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1342  			scan_el_attrcount += ret;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1343  			if (channels[i].type == IIO_TIMESTAMP)
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1344  				indio_dev->scan_index_timestamp =
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1345  					channels[i].scan_index;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1346  		}
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1347  		if (indio_dev->masklength && buffer->scan_mask == NULL) {
3862828a903d3c Andy Shevchenko    2019-03-04  1348  			buffer->scan_mask = bitmap_zalloc(indio_dev->masklength,
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1349  							  GFP_KERNEL);
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1350  			if (buffer->scan_mask == NULL) {
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1351  				ret = -ENOMEM;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1352  				goto error_cleanup_dynamic;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1353  			}
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1354  		}
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1355  	}
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1356  
418ff389a5a48a Alexandru Ardelean 2021-02-01  1357  	attrn = buffer_attrcount + scan_el_attrcount + ARRAY_SIZE(iio_buffer_attrs);
418ff389a5a48a Alexandru Ardelean 2021-02-01  1358  	attr = kcalloc(attrn + 1, sizeof(struct attribute *), GFP_KERNEL);
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1359  	if (!attr) {
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1360  		ret = -ENOMEM;
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1361  		goto error_free_scan_mask;
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1362  	}
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1363  
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1364  	memcpy(attr, iio_buffer_attrs, sizeof(iio_buffer_attrs));
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1365  	if (!buffer->access->set_length)
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1366  		attr[0] = &dev_attr_length_ro.attr;
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1367  
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1368  	if (buffer->access->flags & INDIO_BUFFER_FLAG_FIXED_WATERMARK)
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1369  		attr[2] = &dev_attr_watermark_ro.attr;
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1370  
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1371  	if (buffer->attrs)
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1372  		memcpy(&attr[ARRAY_SIZE(iio_buffer_attrs)], buffer->attrs,
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1373  		       sizeof(struct attribute *) * buffer_attrcount);
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1374  
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1375  	buffer_attrcount += ARRAY_SIZE(iio_buffer_attrs);
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1376  
418ff389a5a48a Alexandru Ardelean 2021-02-01  1377  	attrn = buffer_attrcount;
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1378  
418ff389a5a48a Alexandru Ardelean 2021-02-01  1379  	list_for_each_entry(p, &buffer->scan_el_dev_attr_list, l)
418ff389a5a48a Alexandru Ardelean 2021-02-01  1380  		attr[attrn++] = &p->dev_attr.attr;
418ff389a5a48a Alexandru Ardelean 2021-02-01  1381  
418ff389a5a48a Alexandru Ardelean 2021-02-01  1382  	buffer->buffer_group.name = kasprintf(GFP_KERNEL, "buffer%d", index);
418ff389a5a48a Alexandru Ardelean 2021-02-01  1383  	if (!buffer->buffer_group.name)
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1384  		goto error_free_buffer_attrs;

This needs to be "ret = -ENOMEM;"

e5d01923ab9239 Alexandru Ardelean 2021-02-01  1385  
418ff389a5a48a Alexandru Ardelean 2021-02-01  1386  	buffer->buffer_group.attrs = attr;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1387  
418ff389a5a48a Alexandru Ardelean 2021-02-01  1388  	ret = iio_device_register_sysfs_group(indio_dev, &buffer->buffer_group);
418ff389a5a48a Alexandru Ardelean 2021-02-01  1389  	if (ret)
418ff389a5a48a Alexandru Ardelean 2021-02-01  1390  		goto error_free_buffer_attr_group_name;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1391  
418ff389a5a48a Alexandru Ardelean 2021-02-01  1392  	/* we only need to link the legacy buffer groups for the first buffer */
418ff389a5a48a Alexandru Ardelean 2021-02-01  1393  	if (index > 0)
418ff389a5a48a Alexandru Ardelean 2021-02-01  1394  		return 0;
2dca9525701e36 Alexandru Ardelean 2021-02-01  1395  
418ff389a5a48a Alexandru Ardelean 2021-02-01  1396  	ret = iio_buffer_register_legacy_sysfs_groups(indio_dev, attr,
418ff389a5a48a Alexandru Ardelean 2021-02-01  1397  						      buffer_attrcount,
418ff389a5a48a Alexandru Ardelean 2021-02-01  1398  						      scan_el_attrcount);
2dca9525701e36 Alexandru Ardelean 2021-02-01  1399  	if (ret)
418ff389a5a48a Alexandru Ardelean 2021-02-01  1400  		goto error_free_buffer_attr_group_name;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1401  
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1402  	return 0;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1403  
418ff389a5a48a Alexandru Ardelean 2021-02-01  1404  error_free_buffer_attr_group_name:
418ff389a5a48a Alexandru Ardelean 2021-02-01  1405  	kfree(buffer->buffer_group.name);
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1406  error_free_buffer_attrs:
e5d01923ab9239 Alexandru Ardelean 2021-02-01  1407  	kfree(buffer->buffer_group.attrs);
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1408  error_free_scan_mask:
3862828a903d3c Andy Shevchenko    2019-03-04  1409  	bitmap_free(buffer->scan_mask);
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1410  error_cleanup_dynamic:
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1411  	iio_free_chan_devattr_list(&buffer->scan_el_dev_attr_list);
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1412  
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26 @1413  	return ret;
d967cb6bd4e79c Lars-Peter Clausen 2014-11-26  1414  }

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

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux