çå: [PATCH] irqchip/stm32: Fix "WARNING: invalid free of devm_ allocated
From: huangdaode
Date: Mon Dec 02 2019 - 08:32:50 EST
Yes, I went through the code, found it's a wrong patch, sorry for making the confusion.
Thanks.
-----éäåä-----
åää: Fabien DESSENNE [mailto:fabien.dessenne@xxxxxx]
åéæé: 2019å12æ2æ 21:22
æää: Marc Zyngier <maz@xxxxxxxxxx>; huangdaode <huangdaode@xxxxxxxxxxxxx>
æé: jason@xxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; mcoquelin.stm32@xxxxxxxxx; tglx@xxxxxxxxxxxxx; linux-stm32@xxxxxxxxxxxxxxxxxxxxxxxxxxxx; linux-arm-kernel@xxxxxxxxxxxxxxxxxxx; Alexandre TORGUE <alexandre.torgue@xxxxxx>
äé: 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@xxxxxxxxxxxxx>
>>> ---
>>> Â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.