[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aPEQQMudFKS2gpwl@lizhi-Precision-Tower-5810>
Date: Thu, 16 Oct 2025 11:33:20 -0400
From: Frank Li <Frank.li@....com>
To: Peng Fan <peng.fan@....nxp.com>
Cc: Peng Fan <peng.fan@....com>, Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>,
Dong Aisheng <aisheng.dong@....com>, imx@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/8] firmware: imx: scu-irq: Free mailbox client on
failure
On Thu, Oct 16, 2025 at 10:14:59AM +0800, Peng Fan wrote:
> On Wed, Oct 15, 2025 at 10:32:35AM -0400, Frank Li wrote:
> >On Wed, Oct 15, 2025 at 09:55:03PM +0800, Peng Fan wrote:
> >> On Tue, Oct 14, 2025 at 11:54:36AM -0400, Frank Li wrote:
> >> >On Tue, Oct 14, 2025 at 12:54:39PM +0800, Peng Fan wrote:
> >> >> With mailbox channel freed, it is pointless to keep mailbox client.
> >> >> So free the mailbox client in err path.
> >> >>
> >> >> Signed-off-by: Peng Fan <peng.fan@....com>
> >> >> ---
> >> >> drivers/firmware/imx/imx-scu-irq.c | 1 +
> >> >> 1 file changed, 1 insertion(+)
> >> >>
> >> >> diff --git a/drivers/firmware/imx/imx-scu-irq.c b/drivers/firmware/imx/imx-scu-irq.c
> >> >> index f2b902e95b738fae90af9cbe54da4f488219906f..1fbe4c3de5c1592bfcf2334a83776c25d5ca7a3f 100644
> >> >> --- a/drivers/firmware/imx/imx-scu-irq.c
> >> >> +++ b/drivers/firmware/imx/imx-scu-irq.c
> >> >> @@ -255,6 +255,7 @@ int imx_scu_enable_general_irq_channel(struct device *dev)
> >> >>
> >> >> free_ch:
> >> >> mbox_free_channel(ch);
> >> >> + devm_kfree(dev, cl);
> >> >
> >> >
> >> >you use devm_kmalloc(), when return failure, framework will auto free cl.
> >> >
> >> >Avoid mixing manual free and management free code.
> >> >
> >> >So I think this patch is not neccesary.
> >>
> >> Actually in imx-scu.c, there is only a warning message if this API call returns
> >> error. So need to free here.
> >
> >what's warning?
>
> When imx_scu_enable_general_irq_channel() fails, there is only a warning
> printed out as below, the probe continues.
>
> ret = imx_scu_enable_general_irq_channel(dev);
> if (ret)
> dev_warn(dev,
> "failed to enable general irq channel: %d\n", ret);
>
> dev_info(dev, "NXP i.MX SCU Initialized\n");
>
> return devm_of_platform_populate(dev);
>
> Thanks,
> Peng
It make sense. commit message need be improved to make more clear.
scu-irq: Free mailbox client on failure at imx_scu_enable_general_irq_channel()
The IRQ mailbox is an optional channel and does not need to be kept until
driver removal when an error occurs. Free the allocated memory in the
error path.
There are
ch = mbox_request_channel_byname(cl, "gip3");
if (IS_ERR(ch)) {
ret = PTR_ERR(ch);
dev_err(dev, "failed to request mbox chan gip3, ret %d\n", ret);
devm_kfree(dev, cl);
^^^
return ret;
}
Here should goto free_ch also. keep free at one place.
Frank
>
> >
> >Frank
> >>
> >> Thanks
> >> Peng
> >>
> >> >
> >> >Frank
> >> >>
> >> >> return ret;
> >> >> }
> >> >>
> >> >> --
> >> >> 2.37.1
> >> >>
Powered by blists - more mailing lists