Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] firmware: imx: dsp: fix mailbox channel leak on kasprintf failure
@ 2026-08-13  9:58 Linkai Gong
  2026-08-13 16:40 ` Frank Li
  0 siblings, 1 reply; 2+ messages in thread
From: Linkai Gong @ 2026-08-13  9:58 UTC (permalink / raw)
  To: Frank Li, Sascha Hauer
  Cc: Pengutronix Kernel Team, Fabio Estevam, Oleksij Rempel,
	Daniel Baluta, Shawn Guo, imx, linux-arm-kernel, linux-kernel,
	Linkai Gong

If kasprintf() fails while setting up mailbox channels, already
requested channels from earlier iterations were never freed. Route
the failure through the existing cleanup path.

Fixes: ffbf23d50353 ("firmware: imx: Add DSP IPC protocol interface")
Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>
---
 drivers/firmware/imx/imx-dsp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/imx/imx-dsp.c b/drivers/firmware/imx/imx-dsp.c
index ed79e823157a..7e3f45ddf0c1 100644
--- a/drivers/firmware/imx/imx-dsp.c
+++ b/drivers/firmware/imx/imx-dsp.c
@@ -99,8 +99,10 @@ static int imx_dsp_setup_channels(struct imx_dsp_ipc *dsp_ipc)
 		else
 			chan_name = kasprintf(GFP_KERNEL, "rxdb%d", i - 2);
 
-		if (!chan_name)
-			return -ENOMEM;
+		if (!chan_name) {
+			ret = -ENOMEM;
+			goto out;
+		}
 
 		dsp_chan = &dsp_ipc->chans[i];
 		dsp_chan->name = chan_name;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] firmware: imx: dsp: fix mailbox channel leak on kasprintf failure
  2026-08-13  9:58 [PATCH] firmware: imx: dsp: fix mailbox channel leak on kasprintf failure Linkai Gong
@ 2026-08-13 16:40 ` Frank Li
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2026-08-13 16:40 UTC (permalink / raw)
  To: Linkai Gong
  Cc: Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Oleksij Rempel, Daniel Baluta, Shawn Guo, imx, linux-arm-kernel,
	linux-kernel

On Thu, Aug 13, 2026 at 05:58:18PM +0800, Linkai Gong wrote:
> [You don't often get email from gonglinkai@kylinos.cn. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> If kasprintf() fails while setting up mailbox channels, already
> requested channels from earlier iterations were never freed. Route
> the failure through the existing cleanup path.
>
> Fixes: ffbf23d50353 ("firmware: imx: Add DSP IPC protocol interface")
> Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/firmware/imx/imx-dsp.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> diff --git a/drivers/firmware/imx/imx-dsp.c b/drivers/firmware/imx/imx-dsp.c
> index ed79e823157a..7e3f45ddf0c1 100644
> --- a/drivers/firmware/imx/imx-dsp.c
> +++ b/drivers/firmware/imx/imx-dsp.c
> @@ -99,8 +99,10 @@ static int imx_dsp_setup_channels(struct imx_dsp_ipc *dsp_ipc)
>                 else
>                         chan_name = kasprintf(GFP_KERNEL, "rxdb%d", i - 2);
>
> -               if (!chan_name)
> -                       return -ENOMEM;
> +               if (!chan_name) {
> +                       ret = -ENOMEM;
> +                       goto out;
> +               }
>
>                 dsp_chan = &dsp_ipc->chans[i];
>                 dsp_chan->name = chan_name;
> --
> 2.25.1
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-13 16:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13  9:58 [PATCH] firmware: imx: dsp: fix mailbox channel leak on kasprintf failure Linkai Gong
2026-08-13 16:40 ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox