mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Mergnat <amergnat@baylibre.com>
To: Trevor Wu <trevor.wu@mediatek.com>,
	broonie@kernel.org, lgirdwood@gmail.com, tiwai@suse.com,
	perex@perex.cz, matthias.bgg@gmail.com,
	angelogioacchino.delregno@collabora.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 1/2] ASoC: mediatek: mt8188: fix use-after-free in driver remove path
Date: Mon, 5 Jun 2023 15:21:53 +0200	[thread overview]
Message-ID: <d94b5f07-aa37-f4ec-252b-ff1a96b89326@baylibre.com> (raw)
In-Reply-To: <20230601033318.10408-2-trevor.wu@mediatek.com>

On 01/06/2023 05:33, Trevor Wu wrote:
> During mt8188_afe_init_clock(), mt8188_audsys_clk_register() was called
> followed by several other devm functions. The caller of
> mt8188_afe_init_clock() utilized devm_add_action_or_reset() to call
> mt8188_afe_deinit_clock(). However, the order was incorrect, causing a
> use-after-free issue during remove time.
> 
> At probe time, the order of calls was:
> 1. mt8188_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. mt8188_audsys_clk_unregister
> 3. free afe_priv->clk[i]
> 2. free afe_priv->clk
> 
> To resolve the problem, it's necessary to move devm_add_action_or_reset()
> to the appropriate position so that the remove order can be 3->2->1.

Sounds good

Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>

-- 
Regards,
Alexandre


  parent reply	other threads:[~2023-06-05 13:22 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 [this message]
2023-06-01  3:33 ` [PATCH v2 2/2] ASoC: mediatek: mt8195: " Trevor Wu
2023-06-01 10:02   ` AngeloGioacchino Del Regno
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=d94b5f07-aa37-f4ec-252b-ff1a96b89326@baylibre.com \
    --to=amergnat@baylibre.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --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®