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]
Message-ID: <202209270726.iTLNBc3Y-lkp@intel.com>
Date:   Tue, 27 Sep 2022 11:44:37 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org, Marcus Folkesson <marcus.folkesson@...il.com>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>,
        Andy Shevchenko <andy.shevchenko@...il.com>
Subject: [jic23-iio:testing 55/63] drivers/iio/adc/mcp3911.c:441
 mcp3911_probe() warn: passing zero to 'PTR_ERR'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git testing
head:   df957373c1649c74b78bf2fcfd144f0c3baa68a5
commit: 08a65f61db69ae4850c3c15e8fbe6293a09a998d [55/63] iio: adc: mcp3911: add support for interrupts
config: openrisc-randconfig-m041-20220926
compiler: or1k-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 <dan.carpenter@...cle.com>

smatch warnings:
drivers/iio/adc/mcp3911.c:441 mcp3911_probe() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +441 drivers/iio/adc/mcp3911.c

3a89b289df5df4 Marcus Folkesson 2018-08-08  366  static int mcp3911_probe(struct spi_device *spi)
3a89b289df5df4 Marcus Folkesson 2018-08-08  367  {
3a89b289df5df4 Marcus Folkesson 2018-08-08  368  	struct iio_dev *indio_dev;
3a89b289df5df4 Marcus Folkesson 2018-08-08  369  	struct mcp3911 *adc;
3a89b289df5df4 Marcus Folkesson 2018-08-08  370  	int ret;
3a89b289df5df4 Marcus Folkesson 2018-08-08  371  
3a89b289df5df4 Marcus Folkesson 2018-08-08  372  	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc));
3a89b289df5df4 Marcus Folkesson 2018-08-08  373  	if (!indio_dev)
3a89b289df5df4 Marcus Folkesson 2018-08-08  374  		return -ENOMEM;
3a89b289df5df4 Marcus Folkesson 2018-08-08  375  
3a89b289df5df4 Marcus Folkesson 2018-08-08  376  	adc = iio_priv(indio_dev);
3a89b289df5df4 Marcus Folkesson 2018-08-08  377  	adc->spi = spi;
3a89b289df5df4 Marcus Folkesson 2018-08-08  378  
3a89b289df5df4 Marcus Folkesson 2018-08-08  379  	adc->vref = devm_regulator_get_optional(&adc->spi->dev, "vref");
3a89b289df5df4 Marcus Folkesson 2018-08-08  380  	if (IS_ERR(adc->vref)) {
3a89b289df5df4 Marcus Folkesson 2018-08-08  381  		if (PTR_ERR(adc->vref) == -ENODEV) {
3a89b289df5df4 Marcus Folkesson 2018-08-08  382  			adc->vref = NULL;
3a89b289df5df4 Marcus Folkesson 2018-08-08  383  		} else {
3a89b289df5df4 Marcus Folkesson 2018-08-08  384  			dev_err(&adc->spi->dev,
3a89b289df5df4 Marcus Folkesson 2018-08-08  385  				"failed to get regulator (%ld)\n",
3a89b289df5df4 Marcus Folkesson 2018-08-08  386  				PTR_ERR(adc->vref));
3a89b289df5df4 Marcus Folkesson 2018-08-08  387  			return PTR_ERR(adc->vref);
3a89b289df5df4 Marcus Folkesson 2018-08-08  388  		}
3a89b289df5df4 Marcus Folkesson 2018-08-08  389  
3a89b289df5df4 Marcus Folkesson 2018-08-08  390  	} else {
3a89b289df5df4 Marcus Folkesson 2018-08-08  391  		ret = regulator_enable(adc->vref);
3a89b289df5df4 Marcus Folkesson 2018-08-08  392  		if (ret)
3a89b289df5df4 Marcus Folkesson 2018-08-08  393  			return ret;
0e0a07adaff971 Marcus Folkesson 2022-08-15  394  
0e0a07adaff971 Marcus Folkesson 2022-08-15  395  		ret = devm_add_action_or_reset(&spi->dev,
0e0a07adaff971 Marcus Folkesson 2022-08-15  396  				mcp3911_cleanup_regulator, adc->vref);
0e0a07adaff971 Marcus Folkesson 2022-08-15  397  		if (ret)
0e0a07adaff971 Marcus Folkesson 2022-08-15  398  			return ret;
3a89b289df5df4 Marcus Folkesson 2018-08-08  399  	}
3a89b289df5df4 Marcus Folkesson 2018-08-08  400  
0e0a07adaff971 Marcus Folkesson 2022-08-15  401  	adc->clki = devm_clk_get_enabled(&adc->spi->dev, NULL);
3a89b289df5df4 Marcus Folkesson 2018-08-08  402  	if (IS_ERR(adc->clki)) {
3a89b289df5df4 Marcus Folkesson 2018-08-08  403  		if (PTR_ERR(adc->clki) == -ENOENT) {
3a89b289df5df4 Marcus Folkesson 2018-08-08  404  			adc->clki = NULL;
3a89b289df5df4 Marcus Folkesson 2018-08-08  405  		} else {
3a89b289df5df4 Marcus Folkesson 2018-08-08  406  			dev_err(&adc->spi->dev,
3a89b289df5df4 Marcus Folkesson 2018-08-08  407  				"failed to get adc clk (%ld)\n",
3a89b289df5df4 Marcus Folkesson 2018-08-08  408  				PTR_ERR(adc->clki));
0e0a07adaff971 Marcus Folkesson 2022-08-15  409  			return PTR_ERR(adc->clki);
3a89b289df5df4 Marcus Folkesson 2018-08-08  410  		}
3a89b289df5df4 Marcus Folkesson 2018-08-08  411  	}
3a89b289df5df4 Marcus Folkesson 2018-08-08  412  
4efc1c614d3348 Jonathan Cameron 2021-12-05  413  	ret = mcp3911_config(adc);
3a89b289df5df4 Marcus Folkesson 2018-08-08  414  	if (ret)
0e0a07adaff971 Marcus Folkesson 2022-08-15  415  		return ret;
3a89b289df5df4 Marcus Folkesson 2018-08-08  416  
08a65f61db69ae Marcus Folkesson 2022-08-15  417  	if (device_property_read_bool(&adc->spi->dev, "microchip,data-ready-hiz"))
08a65f61db69ae Marcus Folkesson 2022-08-15  418  		ret = mcp3911_update(adc, MCP3911_REG_STATUSCOM, MCP3911_STATUSCOM_DRHIZ,
08a65f61db69ae Marcus Folkesson 2022-08-15  419  				0, 2);
08a65f61db69ae Marcus Folkesson 2022-08-15  420  	else
08a65f61db69ae Marcus Folkesson 2022-08-15  421  		ret = mcp3911_update(adc, MCP3911_REG_STATUSCOM, MCP3911_STATUSCOM_DRHIZ,
08a65f61db69ae Marcus Folkesson 2022-08-15  422  				MCP3911_STATUSCOM_DRHIZ, 2);
08a65f61db69ae Marcus Folkesson 2022-08-15  423  	if (ret)
08a65f61db69ae Marcus Folkesson 2022-08-15  424  		return ret;
08a65f61db69ae Marcus Folkesson 2022-08-15  425  
3a89b289df5df4 Marcus Folkesson 2018-08-08  426  	indio_dev->name = spi_get_device_id(spi)->name;
3a89b289df5df4 Marcus Folkesson 2018-08-08  427  	indio_dev->modes = INDIO_DIRECT_MODE;
3a89b289df5df4 Marcus Folkesson 2018-08-08  428  	indio_dev->info = &mcp3911_info;
3a89b289df5df4 Marcus Folkesson 2018-08-08  429  	spi_set_drvdata(spi, indio_dev);
3a89b289df5df4 Marcus Folkesson 2018-08-08  430  
3a89b289df5df4 Marcus Folkesson 2018-08-08  431  	indio_dev->channels = mcp3911_channels;
3a89b289df5df4 Marcus Folkesson 2018-08-08  432  	indio_dev->num_channels = ARRAY_SIZE(mcp3911_channels);
3a89b289df5df4 Marcus Folkesson 2018-08-08  433  
3a89b289df5df4 Marcus Folkesson 2018-08-08  434  	mutex_init(&adc->lock);
3a89b289df5df4 Marcus Folkesson 2018-08-08  435  
08a65f61db69ae Marcus Folkesson 2022-08-15  436  	if (spi->irq > 0) {
08a65f61db69ae Marcus Folkesson 2022-08-15  437  		adc->trig = devm_iio_trigger_alloc(&spi->dev, "%s-dev%d",
08a65f61db69ae Marcus Folkesson 2022-08-15  438  				indio_dev->name,
08a65f61db69ae Marcus Folkesson 2022-08-15  439  				iio_device_id(indio_dev));
08a65f61db69ae Marcus Folkesson 2022-08-15  440  		if (!adc->trig)
08a65f61db69ae Marcus Folkesson 2022-08-15 @441  			return PTR_ERR(adc->trig);

This is return 0;  It should be return -ENOMEM;

08a65f61db69ae Marcus Folkesson 2022-08-15  442  
08a65f61db69ae Marcus Folkesson 2022-08-15  443  		adc->trig->ops = &mcp3911_trigger_ops;
08a65f61db69ae Marcus Folkesson 2022-08-15  444  		iio_trigger_set_drvdata(adc->trig, adc);
08a65f61db69ae Marcus Folkesson 2022-08-15  445  		ret = devm_iio_trigger_register(&spi->dev, adc->trig);
08a65f61db69ae Marcus Folkesson 2022-08-15  446  		if (ret)
08a65f61db69ae Marcus Folkesson 2022-08-15  447  			return ret;
08a65f61db69ae Marcus Folkesson 2022-08-15  448  
08a65f61db69ae Marcus Folkesson 2022-08-15  449  		/*
08a65f61db69ae Marcus Folkesson 2022-08-15  450  		 * The device generates interrupts as long as it is powered up.
08a65f61db69ae Marcus Folkesson 2022-08-15  451  		 * Some platforms might not allow the option to power it down so
08a65f61db69ae Marcus Folkesson 2022-08-15  452  		 * don't enable the interrupt to avoid extra load on the system.
08a65f61db69ae Marcus Folkesson 2022-08-15  453  		 */
08a65f61db69ae Marcus Folkesson 2022-08-15  454  		ret = devm_request_irq(&spi->dev, spi->irq,
08a65f61db69ae Marcus Folkesson 2022-08-15  455  				&iio_trigger_generic_data_rdy_poll, IRQF_NO_AUTOEN | IRQF_ONESHOT,
08a65f61db69ae Marcus Folkesson 2022-08-15  456  				indio_dev->name, adc->trig);
08a65f61db69ae Marcus Folkesson 2022-08-15  457  		if (ret)
08a65f61db69ae Marcus Folkesson 2022-08-15  458  			return ret;
08a65f61db69ae Marcus Folkesson 2022-08-15  459  	}
08a65f61db69ae Marcus Folkesson 2022-08-15  460  
5db9f38d394f12 Marcus Folkesson 2022-08-15  461  	ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev,
5db9f38d394f12 Marcus Folkesson 2022-08-15  462  			NULL,
5db9f38d394f12 Marcus Folkesson 2022-08-15  463  			mcp3911_trigger_handler, NULL);
5db9f38d394f12 Marcus Folkesson 2022-08-15  464  	if (ret)
5db9f38d394f12 Marcus Folkesson 2022-08-15  465  		return ret;
5db9f38d394f12 Marcus Folkesson 2022-08-15  466  
0e0a07adaff971 Marcus Folkesson 2022-08-15  467  	return devm_iio_device_register(&adc->spi->dev, indio_dev);
3a89b289df5df4 Marcus Folkesson 2018-08-08  468  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ