Skip to contentSkip to conversation

drivers/pinctrl/pinctrl-cy8c95x0.c:1325 cy8c95x0_irq_setup() warn: passing positive error code '1' to 'dev_err_probe'

PATCH Dan Carpenter 2 participants 3 messages Feb 27 GPIO

lore
Share & tools
lore

Dan Carpenter

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Andy Shevchenko <[email protected]>
CC: Linus Walleij <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
head:   a901e8705f89f3616fad3bb6aeddba33be86b08a
commit: 014884732095b982412d13d3220c3fe8483b9b3e [16/22] pinctrl: cy8c95x0: Unify messages with help of dev_err_probe()

:::::: branch date: 11 hours ago
:::::: commit date: 12 hours ago
config: x86_64-randconfig-161-20260227 (https://download.01.org/0day-ci/archive/20260227/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch version: v0.5.0-8994-gd50c5a4c

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/pinctrl/pinctrl-cy8c95x0.c:1325 cy8c95x0_irq_setup() warn: passing positive error code '1' to 'dev_err_probe'

vim +1325 drivers/pinctrl/pinctrl-cy8c95x0.c

e6cbbe42944de9 Patrick Rudolph 2022-08-16  1308  
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1309  static int cy8c95x0_irq_setup(struct cy8c95x0_pinctrl *chip, int irq)
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1310  {
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1311  	struct gpio_irq_chip *girq = &chip->gpio_chip.irq;
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1312  	DECLARE_BITMAP(pending_irqs, MAX_LINE);
970dacb3b9f0fe Andy Shevchenko 2026-02-23  1313  	struct device *dev = chip->dev;
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1314  	int ret;
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1315  
5ffb2da4a38fd8 Andy Shevchenko 2026-02-23  1316  	ret = devm_mutex_init(chip->dev, &chip->irq_lock);
5ffb2da4a38fd8 Andy Shevchenko 2026-02-23  1317  	if (ret)
5ffb2da4a38fd8 Andy Shevchenko 2026-02-23  1318  		return ret;
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1319  
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1320  	bitmap_zero(pending_irqs, MAX_LINE);
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1321  
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1322  	/* Read IRQ status register to clear all pending interrupts */
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1323  	ret = cy8c95x0_irq_pending(chip, pending_irqs);
014884732095b9 Andy Shevchenko 2026-02-23  1324  	if (ret)
014884732095b9 Andy Shevchenko 2026-02-23 @1325  		return dev_err_probe(dev, ret, "failed to clear irq status register\n");
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1326  
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1327  	/* Mask all interrupts */
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1328  	bitmap_fill(chip->irq_mask, MAX_LINE);
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1329  
f5d620254c9787 Andy Shevchenko 2022-09-02  1330  	gpio_irq_chip_set_chip(girq, &cy8c95x0_irqchip);
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1331  
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1332  	/* This will let us handle the parent IRQ in the driver */
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1333  	girq->parent_handler = NULL;
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1334  	girq->num_parents = 0;
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1335  	girq->parents = NULL;
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1336  	girq->default_type = IRQ_TYPE_NONE;
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1337  	girq->handler = handle_simple_irq;
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1338  	girq->threaded = true;
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1339  
970dacb3b9f0fe Andy Shevchenko 2026-02-23  1340  	return devm_request_threaded_irq(dev, irq, NULL, cy8c95x0_irq_handler,
1ddee69108d305 Andy Shevchenko 2025-01-17  1341  					 IRQF_ONESHOT | IRQF_SHARED,
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1342  					 dev_name(chip->dev), chip);
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1343  }
e6cbbe42944de9 Patrick Rudolph 2022-08-16  1344  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw
Quoted 3 lines · Dan Carpenter
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
head:   a901e8705f89f3616fad3bb6aeddba33be86b08a
commit: 014884732095b982412d13d3220c3fe8483b9b3e [16/22] pinctrl: cy8c95x0: Unify messages with help of dev_err_probe()

False positive. This commit didn't change the previous behaviour. Perhaps smatch complained earlier?

But thanks, I'm going to address this right away!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 7 lines · Andy Shevchenko
Quoted 3 lines · Dan Carpenter
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
head:   a901e8705f89f3616fad3bb6aeddba33be86b08a
commit: 014884732095b982412d13d3220c3fe8483b9b3e [16/22] pinctrl: cy8c95x0: Unify messages with help of dev_err_probe()

False positive. This commit didn't change the previous behaviour. Perhaps smatch complained earlier?

Smatch only detected it when we changed to dev_err_probe(). We could make a check to detect the bug in the original code I suppose. Let me add it as a todo.

KTODO: create static checker rule about positive returns from probe()

Description: The cy8c95x0_irq_setup() is called from cy8c95x0_probe() and probe() should only return zero or negative error codes. Make a list of positive returns. Then check if this is a probe() function and we're returning a positive. Ask on the [email protected] mailing list if you want help writing this check.

regards,
dan carpenter