Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging:iio:spear_adc: Fix IRQ check

The test in the spear_adc driver which checks whether the IRQ number returned
by platform_get_irq() has multiple problems. It accepts 0 even though this is
an invalid IRQ. It also rejects IRQ numbers that are larger or equal than
NR_IRQS. First of all drivers should never need to reference NR_IRQS and
secondly with CONFIG_SPARSE_IRQ NR_IRQS is not the upper limit, so the check
might reject valid IRQ numbers. This patch modifies the check to only test
against less or equal to 0.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Stefan Roese <sr@denx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Lars-Peter Clausen and committed by
Jonathan Cameron
a47f6e08 2918ad14

+1 -1
+1 -1
drivers/staging/iio/adc/spear_adc.c
··· 333 333 } 334 334 335 335 irq = platform_get_irq(pdev, 0); 336 - if ((irq < 0) || (irq >= NR_IRQS)) { 336 + if (irq <= 0) { 337 337 dev_err(dev, "failed getting interrupt resource\n"); 338 338 ret = -EINVAL; 339 339 goto errout3;