From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Trevor Wu <trevor.wu@mediatek.com>,
broonie@kernel.org, lgirdwood@gmail.com, tiwai@suse.com,
perex@perex.cz, matthias.bgg@gmail.com
Cc: dianders@chromium.org, alsa-devel@alsa-project.org,
linux-mediatek@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] ASoC: mediatek: mt8195: fix use-after-free in driver remove path
Date: Thu, 1 Jun 2023 12:02:42 +0200 [thread overview]
Message-ID: <b7864c7d-172e-9903-278c-63df45f6a0ff@collabora.com> (raw)
In-Reply-To: <20230601033318.10408-3-trevor.wu@mediatek.com>
Il 01/06/23 05:33, Trevor Wu ha scritto:
> During mt8195_afe_init_clock(), mt8195_audsys_clk_register() was called
> followed by several other devm functions. At mt8195_afe_deinit_clock()
> located at mt8195_afe_pcm_dev_remove(), mt8195_audsys_clk_unregister()
> was called.
>
> However, there was an issue with the order in which these functions were
> called. Specifically, the remove callback of platform_driver was called
> before devres released the resource, resulting in a use-after-free issue
> during remove time.
>
> At probe time, the order of calls was:
> 1. mt8195_audsys_clk_register
> 2. afe_priv->clk = devm_kcalloc
> 3. afe_priv->clk[i] = devm_clk_get
>
> At remove time, the order of calls was:
> 1. mt8195_audsys_clk_unregister
> 3. free afe_priv->clk[i]
> 2. free afe_priv->clk
>
> To resolve the problem, we can utilize devm_add_action_or_reset() in
> mt8195_audsys_clk_register() so that the remove order can be changed to
> 3->2->1.
>
> Fixes: 6746cc858259 ("ASoC: mediatek: mt8195: add platform driver")
> Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
> Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
next prev parent reply other threads:[~2023-06-01 10:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-01 3:33 [PATCH v2 0/2] ASoC: mediatek: " Trevor Wu
2023-06-01 3:33 ` [PATCH v2 1/2] ASoC: mediatek: mt8188: " Trevor Wu
2023-06-01 10:02 ` AngeloGioacchino Del Regno
2023-06-05 13:21 ` Alexandre Mergnat
2023-06-01 3:33 ` [PATCH v2 2/2] ASoC: mediatek: mt8195: " Trevor Wu
2023-06-01 10:02 ` AngeloGioacchino Del Regno [this message]
2023-06-05 13:27 ` Alexandre Mergnat
2023-06-01 15:44 ` [PATCH v2 0/2] ASoC: mediatek: " Mark Brown
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=b7864c7d-172e-9903-278c-63df45f6a0ff@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=dianders@chromium.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=trevor.wu@mediatek.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
all inboxes | Powered by JetHome®