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: <36fa5481-36f8-415a-b4dc-8831878cab2d@kili.mountain>
Date:   Thu, 11 May 2023 14:00:47 +0300
From:   Dan Carpenter <dan.carpenter@...aro.org>
To:     oe-kbuild@...ts.linux.dev, ChiaEn Wu <chiaen_wu@...htek.com>
Cc:     lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
        linux-kernel@...r.kernel.org,
        Sebastian Reichel <sebastian.reichel@...labora.com>,
        ChiYuan Huang <cy_huang@...htek.com>
Subject: drivers/power/supply/rt9467-charger.c:1026
 rt9467_request_interrupt() warn: passing zero to 'dev_err_probe'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   d295b66a7b66ed504a827b58876ad9ea48c0f4a8
commit: 6f7f70e3a8dd1fbce95eaea2a8eff70f01363c00 power: supply: rt9467: Add Richtek RT9467 charger driver
config: m68k-randconfig-m031-20230511 (https://download.01.org/0day-ci/archive/20230511/202305111228.bHLWU6bq-lkp@intel.com/config)
compiler: m68k-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/202305111228.bHLWU6bq-lkp@intel.com/

smatch warnings:
drivers/power/supply/rt9467-charger.c:1026 rt9467_request_interrupt() warn: passing zero to 'dev_err_probe'

vim +/dev_err_probe +1026 drivers/power/supply/rt9467-charger.c

6f7f70e3a8dd1f ChiaEn Wu 2023-01-03   995  static int rt9467_request_interrupt(struct rt9467_chg_data *data)
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03   996  {
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03   997  	struct device *dev = data->dev;
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03   998  	static const struct {
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03   999  		const char *name;
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1000  		int hwirq;
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1001  		irq_handler_t handler;
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1002  	} rt9467_exclusive_irqs[] = {
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1003  		RT9467_IRQ_DESC(statc, statc, RT9467_IRQ_TS_STATC),
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1004  		RT9467_IRQ_DESC(wdt, wdt, RT9467_IRQ_WDTMR),
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1005  		RT9467_IRQ_DESC(attach, usb_state, RT9467_IRQ_ATTACH),
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1006  		RT9467_IRQ_DESC(detach,	usb_state, RT9467_IRQ_DETACH),
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1007  		RT9467_IRQ_DESC(aiclmeas, aiclmeas, RT9467_IRQ_CHG_AICLM),
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1008  	}, rt9466_exclusive_irqs[] = {
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1009  		RT9467_IRQ_DESC(statc, statc, RT9467_IRQ_TS_STATC),
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1010  		RT9467_IRQ_DESC(wdt, wdt, RT9467_IRQ_WDTMR),
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1011  		RT9467_IRQ_DESC(aiclmeas, aiclmeas, RT9467_IRQ_CHG_AICLM),
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1012  	}, *chg_irqs;
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1013  	int num_chg_irqs, i, virq, ret;
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1014  
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1015  	if (data->vid == RT9466_VID) {
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1016  		chg_irqs = rt9466_exclusive_irqs;
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1017  		num_chg_irqs = ARRAY_SIZE(rt9466_exclusive_irqs);
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1018  	} else {
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1019  		chg_irqs = rt9467_exclusive_irqs;
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1020  		num_chg_irqs = ARRAY_SIZE(rt9467_exclusive_irqs);
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1021  	}
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1022  
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1023  	for (i = 0; i < num_chg_irqs; i++) {
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1024  		virq = regmap_irq_get_virq(data->irq_chip_data, chg_irqs[i].hwirq);
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1025  		if (virq <= 0)
                                                            ^^^^^^^^^
It's unfortunate that regmap_irq_get_virq() returns zero on failure...
*sad face*.  Someone should fix that.  The IRQ functions are that way
for ancient historical reasons and it leads to a lot of mess.

6f7f70e3a8dd1f ChiaEn Wu 2023-01-03 @1026  			return dev_err_probe(dev, virq, "Failed to get (%s) irq\n",
                                                                                          ^^^^
This will return success and lead to a crash.

6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1027  					     chg_irqs[i].name);
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1028  
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1029  		ret = devm_request_threaded_irq(dev, virq, NULL, chg_irqs[i].handler,
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1030  						IRQF_ONESHOT, chg_irqs[i].name, data);
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1031  		if (ret)
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1032  			return dev_err_probe(dev, ret, "Failed to request (%s) irq\n",
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1033  					     chg_irqs[i].name);
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1034  	}
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1035  
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1036  	return 0;
6f7f70e3a8dd1f ChiaEn Wu 2023-01-03  1037  }

-- 
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