irqchip/stm32: Fix "WARNING: invalid free of devm_ allocated
Subsystems (2)
PATCH 1/1 irqchip/stm32: Fix "WARNING: invalid free of devm_ allocated
Since devm_ allocated data can be automaitcally released, it's no need to free it apparently, just remove it.
stm32mp1-exti device")
--- drivers/irqchip/irq-stm32-exti.c | 2 -- 1 file changed, 2 deletions(-)
drivers/irqchip/irq-stm32-exti.c +0 -2
@@ -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; }
Signature · 1 line
2.8.1
Marc Zyngier
AppliedQuoted 16 lines · Daode Huang
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 forstm32mp1-exti device")
Signed-off-by Daode Huang <[email protected]>--- drivers/irqchip/irq-stm32-exti.c | 2 -- 1 file changed, 2 deletions(-)drivers/irqchip/irq-stm32-exti.c +0
-0
drivers/irqchip/irq-stm32-exti.c static int __init stm32_exti_init(const struct · line 784
Quoted 8 lines
drivers/irqchip/irq-stm32-exti.c +0
-2@@ -779,8 +779,6 @@ static int __init stm32_exti_init(const structstm32_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.
Signature · 1 line
Jazz is not dead. It just smells funny...
Quoted 11 lines · Marc Zyngier
Quoted 10 lines · Daode Huang
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 forstm32mp1-exti device")
Signed-off-by Daode Huang <[email protected]>--- drivers/irqchip/irq-stm32-exti.c | 2 -- 1 file changed, 2 deletions(-)
Quoted 16 lines
Quoted 6 lines
drivers/irqchip/irq-stm32-exti.c +0
-0drivers/irqchip/irq-stm32-exti.c static int __init stm32_exti_init(const struct · line 784
Quoted 8 lines
drivers/irqchip/irq-stm32-exti.c +0
-2@@ -779,8 +779,6 @@ static int __init stm32_exti_init(const structstm32_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.
Signature · 1 line
Jazz is not dead. It just smells funny...
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
Quoted 36 lines · Marc Zyngier
Quoted 11 lines · Marc Zyngier
Quoted 10 lines · Daode Huang
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 forstm32mp1-exti device")
Signed-off-by Daode Huang <[email protected]>---
drivers/irqchip/irq-stm32-exti.c | 2 --1 file changed, 2 deletions(-)Quoted 16 lines
Quoted 8 lines
drivers/irqchip/irq-stm32-exti.c +0
-0@@ -779,8 +779,6 @@ static int __init stm32_exti_init(const structstm32_exti_drv_data *drv_data, irq_domain_remove(domain);Quoted 6 lines
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.
Yes, I went through the code, found it's a wrong patch, sorry for making the confusion.
Thanks.
-----邮件原件-----
发件人: Fabien DESSENNE [mailto:[email protected]]
发送时间: 2019年12月2日 21:22
收件人: Marc Zyngier <[email protected]>; huangdaode <[email protected]>
抄送: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Alexandre TORGUE <[email protected]> 主题: 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
Quoted 36 lines · Marc Zyngier
Quoted 11 lines · Marc Zyngier
Quoted 10 lines · Daode Huang
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 forstm32mp1-exti device")
Signed-off-by Daode Huang <[email protected]>---
drivers/irqchip/irq-stm32-exti.c | 2 --1 file changed, 2 deletions(-)Quoted 16 lines
Quoted 8 lines
drivers/irqchip/irq-stm32-exti.c +0
-0@@ -779,8 +779,6 @@ static int __init stm32_exti_init(const structstm32_exti_drv_data *drv_data, irq_domain_remove(domain);Quoted 6 lines
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.