* [PATCH] irqchip/stm32: Fix "WARNING: invalid free of devm_ allocated @ 2019-11-28 9:04 Daode Huang 2019-12-02 12:29 ` Marc Zyngier 0 siblings, 1 reply; 5+ messages in thread From: Daode Huang @ 2019-11-28 9:04 UTC (permalink / raw) To: tglx, jason, maz, mcoquelin.stm32, alexandre.torgue, fabien.dessenne Cc: linux-kernel, linux-arm-kernel, linux-stm32 Since devm_ allocated data can be automaitcally released, it's no need to free it apparently, just remove it. Fixes: cfbf9e497094 ("irqchip/stm32: Use a platform driver for stm32mp1-exti device") Signed-off-by: Daode Huang <huangdaode@hisilicon.com> --- drivers/irqchip/irq-stm32-exti.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c index e00f2fa..46ec0af 100644 --- a/drivers/irqchip/irq-stm32-exti.c +++ b/drivers/irqchip/irq-stm32-exti.c @@ -779,8 +779,6 @@ static int __init stm32_exti_init(const struct stm32_exti_drv_data *drv_data, irq_domain_remove(domain); out_unmap: iounmap(host_data->base); - kfree(host_data->chips_data); - kfree(host_data); return ret; } -- 2.8.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] irqchip/stm32: Fix "WARNING: invalid free of devm_ allocated 2019-11-28 9:04 [PATCH] irqchip/stm32: Fix "WARNING: invalid free of devm_ allocated Daode Huang @ 2019-12-02 12:29 ` Marc Zyngier 2019-12-02 12:40 ` Marc Zyngier 0 siblings, 1 reply; 5+ messages in thread From: Marc Zyngier @ 2019-12-02 12:29 UTC (permalink / raw) To: Daode Huang Cc: jason, linux-kernel, fabien.dessenne, mcoquelin.stm32, tglx, linux-stm32, linux-arm-kernel, alexandre.torgue On 2019-11-28 09:04, Daode Huang wrote: > Since devm_ allocated data can be automaitcally released, it's no > need to free it apparently, just remove it. > > Fixes: cfbf9e497094 ("irqchip/stm32: Use a platform driver for > stm32mp1-exti device") > Signed-off-by: Daode Huang <huangdaode@hisilicon.com> > --- > drivers/irqchip/irq-stm32-exti.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/irqchip/irq-stm32-exti.c > b/drivers/irqchip/irq-stm32-exti.c > index e00f2fa..46ec0af 100644 > --- a/drivers/irqchip/irq-stm32-exti.c > +++ b/drivers/irqchip/irq-stm32-exti.c > @@ -779,8 +779,6 @@ static int __init stm32_exti_init(const struct > stm32_exti_drv_data *drv_data, > irq_domain_remove(domain); > out_unmap: > iounmap(host_data->base); > - kfree(host_data->chips_data); > - kfree(host_data); > return ret; > } Applied, thanks. M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] irqchip/stm32: Fix "WARNING: invalid free of devm_ allocated 2019-12-02 12:29 ` Marc Zyngier @ 2019-12-02 12:40 ` Marc Zyngier 2019-12-02 13:22 ` Fabien DESSENNE 0 siblings, 1 reply; 5+ messages in thread From: Marc Zyngier @ 2019-12-02 12:40 UTC (permalink / raw) To: Daode Huang Cc: jason, linux-kernel, fabien.dessenne, mcoquelin.stm32, tglx, linux-stm32, linux-arm-kernel, alexandre.torgue On 2019-12-02 12:29, Marc Zyngier wrote: > On 2019-11-28 09:04, Daode Huang wrote: >> Since devm_ allocated data can be automaitcally released, it's no >> need to free it apparently, just remove it. >> >> Fixes: cfbf9e497094 ("irqchip/stm32: Use a platform driver for >> stm32mp1-exti device") >> Signed-off-by: Daode Huang <huangdaode@hisilicon.com> >> --- >> drivers/irqchip/irq-stm32-exti.c | 2 -- >> 1 file changed, 2 deletions(-) >> >> diff --git a/drivers/irqchip/irq-stm32-exti.c >> b/drivers/irqchip/irq-stm32-exti.c >> index e00f2fa..46ec0af 100644 >> --- a/drivers/irqchip/irq-stm32-exti.c >> +++ b/drivers/irqchip/irq-stm32-exti.c >> @@ -779,8 +779,6 @@ static int __init stm32_exti_init(const struct >> stm32_exti_drv_data *drv_data, >> irq_domain_remove(domain); >> out_unmap: >> iounmap(host_data->base); >> - kfree(host_data->chips_data); >> - kfree(host_data); >> return ret; >> } > > Applied, thanks. Scratch that. This patch is just wrong, and just reading the code makes it obvious. stm32_exti_init() is only called on paths that allocate the memory with kmalloc. Clearly you haven't tried to understand what is going on. M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] irqchip/stm32: Fix "WARNING: invalid free of devm_ allocated 2019-12-02 12:40 ` Marc Zyngier @ 2019-12-02 13:22 ` Fabien DESSENNE 2019-12-02 13:32 ` 答复: " huangdaode 0 siblings, 1 reply; 5+ messages in thread From: Fabien DESSENNE @ 2019-12-02 13:22 UTC (permalink / raw) To: Marc Zyngier, Daode Huang Cc: jason, linux-kernel, mcoquelin.stm32, tglx, linux-stm32, linux-arm-kernel, Alexandre TORGUE Hi Daode, I confirm that this patch is not a good idea, here are some explanations. irq-stm32-exti.c deals with two different purposes: - either it is used to probe the "st,stm32mp1-exti" compatible device. In that case .probe() is invoked and uses devm_kzalloc() to get memory. No need to free memory. -either is it used for other stm32 devices. In that case, there is no probe function, the driver is 'just' init'ed. In that case, devm_kzalloc() is not used and explicit free memory is required. As said by Mark, you have just mixed the two paths. Fabien On 02/12/2019 1:40 PM, Marc Zyngier wrote: > On 2019-12-02 12:29, Marc Zyngier wrote: >> On 2019-11-28 09:04, Daode Huang wrote: >>> Since devm_ allocated data can be automaitcally released, it's no >>> need to free it apparently, just remove it. >>> >>> Fixes: cfbf9e497094 ("irqchip/stm32: Use a platform driver for >>> stm32mp1-exti device") >>> Signed-off-by: Daode Huang <huangdaode@hisilicon.com> >>> --- >>> drivers/irqchip/irq-stm32-exti.c | 2 -- >>> 1 file changed, 2 deletions(-) >>> >>> diff --git a/drivers/irqchip/irq-stm32-exti.c >>> b/drivers/irqchip/irq-stm32-exti.c >>> index e00f2fa..46ec0af 100644 >>> --- a/drivers/irqchip/irq-stm32-exti.c >>> +++ b/drivers/irqchip/irq-stm32-exti.c >>> @@ -779,8 +779,6 @@ static int __init stm32_exti_init(const struct >>> stm32_exti_drv_data *drv_data, >>> irq_domain_remove(domain); >>> out_unmap: >>> iounmap(host_data->base); >>> - kfree(host_data->chips_data); >>> - kfree(host_data); >>> return ret; >>> } >> >> Applied, thanks. > > Scratch that. This patch is just wrong, and just reading the code > makes it obvious. stm32_exti_init() is only called on paths > that allocate the memory with kmalloc. > > Clearly you haven't tried to understand what is going on. > > M. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 5+ messages in thread
* 答复: [PATCH] irqchip/stm32: Fix "WARNING: invalid free of devm_ allocated 2019-12-02 13:22 ` Fabien DESSENNE @ 2019-12-02 13:32 ` huangdaode 0 siblings, 0 replies; 5+ messages in thread From: huangdaode @ 2019-12-02 13:32 UTC (permalink / raw) To: Fabien DESSENNE, Marc Zyngier Cc: jason, linux-kernel, mcoquelin.stm32, tglx, linux-stm32, linux-arm-kernel, Alexandre TORGUE Yes, I went through the code, found it's a wrong patch, sorry for making the confusion. Thanks. -----邮件原件----- 发件人: Fabien DESSENNE [mailto:fabien.dessenne@st.com] 发送时间: 2019年12月2日 21:22 收件人: Marc Zyngier <maz@kernel.org>; huangdaode <huangdaode@hisilicon.com> 抄送: jason@lakedaemon.net; linux-kernel@vger.kernel.org; mcoquelin.stm32@gmail.com; tglx@linutronix.de; linux-stm32@st-md-mailman.stormreply.com; linux-arm-kernel@lists.infradead.org; Alexandre TORGUE <alexandre.torgue@st.com> 主题: Re: [PATCH] irqchip/stm32: Fix "WARNING: invalid free of devm_ allocated Hi Daode, I confirm that this patch is not a good idea, here are some explanations. irq-stm32-exti.c deals with two different purposes: - either it is used to probe the "st,stm32mp1-exti" compatible device. In that case .probe() is invoked and uses devm_kzalloc() to get memory. No need to free memory. -either is it used for other stm32 devices. In that case, there is no probe function, the driver is 'just' init'ed. In that case, devm_kzalloc() is not used and explicit free memory is required. As said by Mark, you have just mixed the two paths. Fabien On 02/12/2019 1:40 PM, Marc Zyngier wrote: > On 2019-12-02 12:29, Marc Zyngier wrote: >> On 2019-11-28 09:04, Daode Huang wrote: >>> Since devm_ allocated data can be automaitcally released, it's no >>> need to free it apparently, just remove it. >>> >>> Fixes: cfbf9e497094 ("irqchip/stm32: Use a platform driver for >>> stm32mp1-exti device") >>> Signed-off-by: Daode Huang <huangdaode@hisilicon.com> >>> --- >>> drivers/irqchip/irq-stm32-exti.c | 2 -- >>> 1 file changed, 2 deletions(-) >>> >>> diff --git a/drivers/irqchip/irq-stm32-exti.c >>> b/drivers/irqchip/irq-stm32-exti.c >>> index e00f2fa..46ec0af 100644 >>> --- a/drivers/irqchip/irq-stm32-exti.c >>> +++ b/drivers/irqchip/irq-stm32-exti.c >>> @@ -779,8 +779,6 @@ static int __init stm32_exti_init(const struct >>> stm32_exti_drv_data *drv_data, >>> irq_domain_remove(domain); >>> out_unmap: >>> iounmap(host_data->base); >>> - kfree(host_data->chips_data); >>> - kfree(host_data); >>> return ret; >>> } >> >> Applied, thanks. > > Scratch that. This patch is just wrong, and just reading the code > makes it obvious. stm32_exti_init() is only called on paths that > allocate the memory with kmalloc. > > Clearly you haven't tried to understand what is going on. > > M. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-12-02 13:33 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-11-28 9:04 [PATCH] irqchip/stm32: Fix "WARNING: invalid free of devm_ allocated Daode Huang 2019-12-02 12:29 ` Marc Zyngier 2019-12-02 12:40 ` Marc Zyngier 2019-12-02 13:22 ` Fabien DESSENNE 2019-12-02 13:32 ` 答复: " huangdaode
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).