]> git.ipfire.org Git - thirdparty/linux.git/commit
mmc: meson-gx: Free irq in release() callback
authorRemi Pommarel <repk@triplefau.lt>
Thu, 10 Jan 2019 23:01:35 +0000 (00:01 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 14 Jan 2019 11:03:04 +0000 (12:03 +0100)
commitbb364890323cca6e43f13e86d190ebf34a7d8cea
tree73b48a1dd6299be611cd61f3bf2ff8667a6dcc1b
parent287b1da6a458a30da2e5be745498d31092ebb001
mmc: meson-gx: Free irq in release() callback

Because the irq was requested through device managed resources API
(devm_request_threaded_irq()) it was freed after meson_mmc_remove()
completion, thus after mmc_free_host() has reclaimed meson_host memory.
As this irq is IRQF_SHARED, while using CONFIG_DEBUG_SHIRQ, its handler
get called by free_irq(). So meson_mmc_irq() was called after the
meson_host memory reclamation and was using invalid memory.

We ended up with the following scenario:
device_release_driver()
meson_mmc_remove()
mmc_free_host() /* Freeing host memory */
...
devres_release_all()
devm_irq_release()
__free_irq()
meson_mmc_irq() /* Uses freed memory */

To avoid this, the irq is released in meson_mmc_remove() and in
mseon_mmc_probe() error path before mmc_free_host() gets called.

Reported-by: Elie Roudninski <xademax@gmail.com>
Signed-off-by: Remi Pommarel <repk@triplefau.lt>
Cc: stable@vger.kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/meson-gx-mmc.c