From: Remi Pommarel <repk@triplefau.lt>
To: Ulf Hansson <ulf.hansson@linaro.org>,
Kevin Hilman <khilman@baylibre.com>
Cc: Elie Roudninski <xademax@gmail.com>,
linux-amlogic@lists.infradead.org, linux-mmc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mmc: meson-gx: Free irq in release() callback
Date: Thu, 10 Jan 2019 23:52:00 +0100 [thread overview]
Message-ID: <20190110225200.GC982@voidbox.localdomain> (raw)
In-Reply-To: <20190110184908.27413-1-repk@triplefau.lt>
On Thu, Jan 10, 2019 at 07:49:08PM +0100, Remi Pommarel wrote:
> 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() before
> mmc_free_host() gets called.
>
Oups, I missed the fact that the same can happen if probe() callback
fails after allocating the irq.
I will send a V2 for that.
--
Remi
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2019-01-10 22:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 18:49 [PATCH] mmc: meson-gx: Free irq in release() callback Remi Pommarel
2019-01-10 22:52 ` Remi Pommarel [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-01-10 17:43 Remi Pommarel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190110225200.GC982@voidbox.localdomain \
--to=repk@triplefau.lt \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=xademax@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).