]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
spi: ppc4xx: handle irq_of_parse_and_map() errors
authorMa Ke <make24@iscas.ac.cn>
Wed, 24 Jul 2024 08:40:47 +0000 (16:40 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:29:01 +0000 (16:29 +0200)
[ Upstream commit 0f245463b01ea254ae90e1d0389e90b0e7d8dc75 ]

Zero and negative number is not a valid IRQ for in-kernel code and the
irq_of_parse_and_map() function returns zero on error.  So this check for
valid IRQs should only accept values > 0.

Fixes: 44dab88e7cc9 ("spi: add spi_ppc4xx driver")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Link: https://patch.msgid.link/20240724084047.1506084-1-make24@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi-ppc4xx.c

index e982d3189fdce88cdadc1e717f3175357fb9f3a7..0d698580194e977e09906469d3a06efe9075d92f 100644 (file)
@@ -411,6 +411,9 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
 
        /* Request IRQ */
        hw->irqnum = irq_of_parse_and_map(np, 0);
+       if (hw->irqnum <= 0)
+               goto free_host;
+
        ret = request_irq(hw->irqnum, spi_ppc4xx_int,
                          0, "spi_ppc4xx_of", (void *)hw);
        if (ret) {