Re: [PATCH] pci: ftpci100: fix of_irq_get() error check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jul 15, 2017 at 11:43 PM, Sergei Shtylyov
<sergei.shtylyov@xxxxxxxxxxxxxxxxxx> wrote:

> of_irq_get() may return a negative error number as well as 0 on failure,
> while the driver only checks for 0, blithely continuing with the call to
> irq_set_chained_handler_and_data() -- that function expects *unsigned int*
> so should probably do nothing when a large IRQ number resulting from a
> conversion of a negative error number is passed to it. The driver then
> probes successfully while being only partly functional...
>
> Check for 'irq <= 0' instead and propagate the negative error number to
> the probe method --  that will allow the deferred probing as well...
>
> Fixes: d3c68e0a7e34 ("PCI: faraday: Add Faraday Technology FTPCI100 PCI Host Bridge driver")
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@xxxxxxxxxxxxxxxxxx>

Looks correct!
Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

> -               return -EINVAL;
> +               return irq ?: -EINVAL;

I thought I knew C but I learn something new all the time.
I had no clue one can use the ternary operator like this.

Linus Walleij



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux