Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: imx@lists.linux.dev, Frank.Li@kernel.org,
	wsa+renesas@sang-engineering.com
Subject: Re: [PATCH v2 01/25] ASoC: amd: acp: Fix .close() being skipped on rollback
Date: Fri, 16 Oct 2026 04:19:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-173760@kernel.org> (raw)
In-Reply-To: <20261015014324.5569-2-phucduc.bui@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] sound/soc/amd: raven: memory leak in acp3x_dma_close()
--

commit 85bba20e9cd8adc1bcd476d2122c1723541d8edd
Author: bui duc phuc <phucduc.bui@gmail.com>

ASoC: amd: acp: Fix .close() being skipped on rollback

snd_pcm_hw_constraint_integer() may return 1, which is then returned
from acp_dma_open(). ASoC only marks the component as opened when
.open() returns 0, so .close() can be skipped on rollback. Return 0
explicitly on success.

> diff --git a/sound/soc/amd/acp/acp-platform.c b/sound/soc/amd/acp/acp-platform.c
> index 6b1e18b31c1c6..f2c8853775ad3 100644
> --- a/sound/soc/amd/acp/acp-platform.c
> +++ b/sound/soc/amd/acp/acp-platform.c
> @@ -248,7 +248,12 @@ static int acp_dma_open(struct snd_soc_component *component, struct snd_pcm_subs
>  	list_add_tail(&stream->list, &chip->stream_list);
>  	spin_unlock_irq(&chip->acp_lock);
>  
> -	return ret;
> +	/*
> +	 * ASoC only marks the component as opened when .open() returns 0.
> +	 * Since snd_pcm_hw_constraint_integer() may return 1, explicitly
> +	 * return 0 to ensure .close() is not skipped on rollback.
> +	 */
> +	return 0;
>  }

[Severity: High]
Is there a memory leak in acp3x_dma_close() related to this subsystem?

Looking at sound/soc/amd/raven/acp3x-pcm-dma.c, the stream instance
structure is allocated on every stream open:

sound/soc/amd/raven/acp3x-pcm-dma.c:acp3x_dma_open() {
    ...
	i2s_data = kzalloc_obj(*i2s_data);
	if (!i2s_data)
		return -EINVAL;
    ...
}

However, when the stream is closed, acp3x_dma_close() returns without calling
kfree() to free the allocated stream instance structure:

sound/soc/amd/raven/acp3x-pcm-dma.c:acp3x_dma_close() {
    ...
	return 0;
}

Could this lead to a memory leak of the i2s_data structure on every stream
closure, allowing a user to drain system memory by repeatedly opening and
closing the device?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015014324.5569-1-phucduc.bui@gmail.com?part=1

  reply	other threads:[~2026-10-16  4:19 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  1:42 [PATCH v2 00/25] ASoC: Fix constraint return value handling phucduc.bui
2026-10-15  1:43 ` [PATCH v2 01/25] ASoC: amd: acp: Fix .close() being skipped on rollback phucduc.bui
2026-10-16  4:19   ` sashiko-bot [this message]
2026-10-16  7:40     ` Bui Duc Phuc
2026-10-15  1:43 ` [PATCH v2 02/25] ASoC: amd: ps: Fix acp63_pdm_dma_close() " phucduc.bui
2026-10-15  1:43 ` [PATCH v2 03/25] ASoC: amd: ps: Fix acp63_sdw_dma_close() " phucduc.bui
2026-10-15  1:43 ` [PATCH v2 04/25] ASoC: amd: raven: Fix acp3x_dma_close() " phucduc.bui
2026-10-16  4:14   ` sashiko-bot
2026-10-15  1:43 ` [PATCH v2 05/25] ASoC: amd: renoir: Fix acp_pdm_dma_close() " phucduc.bui
2026-10-15  1:43 ` [PATCH v2 06/25] ASoC: amd: vangogh: Fix acp5x_dma_close() " phucduc.bui
2026-10-15  1:43 ` [PATCH v2 07/25] ASoC: amd: yc: Fix acp6x_pdm_dma_close() " phucduc.bui
2026-10-15  1:43 ` [PATCH v2 08/25] ASoC: apple: mca: Ensure the DAI is marked as started on success phucduc.bui
2026-10-15  1:43 ` [PATCH v2 09/25] ASoC: atmel: atmel-pcm-pdc: Fix atmel_pcm_close() being skipped on rollback phucduc.bui
2026-10-16  4:16   ` sashiko-bot
2026-10-15  1:43 ` [PATCH v2 10/25] ASoC: codecs: cs42l42: Ensure the DAI is marked as started on success phucduc.bui
2026-10-15  1:43 ` [PATCH v2 11/25] ASoC: codecs: nau8325: " phucduc.bui
2026-10-15  1:43 ` [PATCH v2 12/25] ASoC: codecs: nau8540: " phucduc.bui
2026-10-15  1:43 ` [PATCH v2 13/25] ASoC: codecs: nau8821: " phucduc.bui
2026-10-15  1:43 ` [PATCH v2 14/25] ASoC: codecs: nau8824: " phucduc.bui
2026-10-15  1:43 ` [PATCH v2 15/25] ASoC: codecs: nau8825: " phucduc.bui
2026-10-15  1:43 ` [PATCH v2 16/25] ASoC: codecs: wm8580: " phucduc.bui
2026-10-15  1:43 ` [PATCH v2 17/25] ASoC: codecs: wm8782: " phucduc.bui
2026-10-15  1:43 ` [PATCH v2 18/25] ASoC: imx-pcm-rpmsg: Fix imx_rpmsg_pcm_close() being skipped on rollback phucduc.bui
2026-10-16  4:14   ` sashiko-bot
2026-10-15  1:43 ` [PATCH v2 19/25] ASoC: intel: atom: Fix .shutdown() " phucduc.bui
2026-10-15 10:44   ` Cezary Rojewski
2026-10-16  4:12   ` sashiko-bot
2026-10-15  1:43 ` [PATCH v2 20/25] ASoC: renesas: fsi: Ensure the component is marked as opened on success phucduc.bui
2026-10-15  3:55   ` Kuninori Morimoto
2026-10-15  1:43 ` [PATCH v2 21/25] ASoC: renesas: msiof: Remove redundant period constraint phucduc.bui
2026-10-15  3:56   ` Kuninori Morimoto
2026-10-15  1:43 ` [PATCH v2 22/25] ASoC: renesas: rz-ssi: Ensure the component is marked as opened on success phucduc.bui
2026-10-15  1:43 ` [PATCH v2 23/25] ASoC: renesas: rz-ssi: Remove redundant component open callback phucduc.bui
2026-10-15  1:43 ` [PATCH v2 24/25] ASoC: rockchip: rk3399_gru_sound: Mark the link as started on success phucduc.bui
2026-10-15 11:12 ` [PATCH v2 00/25] ASoC: Fix constraint return value handling Mark Brown
2026-10-16  1:52   ` Bui Duc Phuc
2026-10-16  4:00 ` [PATCH v2 25/25] ASoC: rockchip: rockchip_max98090: Mark the link as started on success phucduc.bui
2026-10-16 10:27   ` Mark Brown
2026-10-16 11:25     ` Bui Duc Phuc

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=sashiko-outbox-173760@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=phucduc.bui@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.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