Re: [PATCH 1/3] mmc: meson-gx: Handle errors from optional IRQ lookup

Bui Duc Phuc <[email protected]>
Newsgroups org.infradead.lists.linux-amlogic,dev.linux.lists.sashiko-reviews
Message-ID <CAABR9nE1r3-2eafWqfTv8kJg7G_urfC0hP36NgqeGt9QPf6NrA@mail.gmail.com>
>
> [Severity: High]
> Does this code pass an uninitialized variable to mmc_gpio_set_cd_irq()
> when the optional IRQ is not present?
>
> If platform_get_irq_optional() returns -ENXIO, the assignment to cd_irq
> is skipped. The uninitialized cd_irq variable is then passed to
> mmc_gpio_set_cd_irq().
>
> If the uninitialized stack value happens to be >= 0, mmc_gpio_set_cd_irq()
> will accept it and overwrite the card-detect IRQ configuration with an
> invalid or random IRQ number.
>
> Could cd_irq be initialized to a negative value when it is declared?
>


Okay, you are right. However, mmc_gpio_set_cd_irq() already checks for
this case:
--------------------
if (!ctx || irq < 0)
        return;
--------------------

I’ll fix this by initializing cd_irq to -ENXIO:

------------------------------
int cd_irq = -ENXIO;
------------------------------

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.