[PATCH 1/3] mmc: meson-gx: Handle errors from optional IRQ lookup
Bui Duc Phuc
phucduc.bui at gmail.com
Wed Aug 12 21:39:04 PDT 2026
>
> [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;
------------------------------
More information about the linux-amlogic
mailing list