linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rqchip/stm32: Remove unneeded call to kfree
@ 2019-07-19 18:46 Hariprasad Kelam
  2019-07-22 10:26 ` Steven Price
  0 siblings, 1 reply; 3+ messages in thread
From: Hariprasad Kelam @ 2019-07-19 18:46 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier, Maxime Coquelin,
	Alexandre Torgue, linux-kernel, linux-stm32, linux-arm-kernel

Memory allocated by devm_ alloc will be freed upon device detachment. So
we may not require free memory.

Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.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.7.4


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

* Re: [PATCH] rqchip/stm32: Remove unneeded call to kfree
  2019-07-19 18:46 [PATCH] rqchip/stm32: Remove unneeded call to kfree Hariprasad Kelam
@ 2019-07-22 10:26 ` Steven Price
  2019-07-23 16:19   ` Hariprasad Kelam
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Price @ 2019-07-22 10:26 UTC (permalink / raw)
  To: Hariprasad Kelam, Thomas Gleixner, Jason Cooper, Marc Zyngier,
	Maxime Coquelin, Alexandre Torgue, linux-kernel, linux-stm32,
	linux-arm-kernel

On 19/07/2019 19:46, Hariprasad Kelam wrote:
> Memory allocated by devm_ alloc will be freed upon device detachment. So
> we may not require free memory.
> 
> Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.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);

In the commit this is based on these variables are not allocated using a
devm_ alloc function:

$ git show e00f2fa | grep -A12 *stm32_exti_host_init
> stm32_exti_host_data *stm32_exti_host_init(const struct stm32_exti_drv_data *dd,
> 					   struct device_node *node)
> {
> 	struct stm32_exti_host_data *host_data;
> 
> 	host_data = kzalloc(sizeof(*host_data), GFP_KERNEL);
> 	if (!host_data)
> 		return NULL;
> 
> 	host_data->drv_data = dd;
> 	host_data->chips_data = kcalloc(dd->bank_nr,
> 					sizeof(struct stm32_exti_chip_data),
> 					GFP_KERNEL);
The function stm32_exti_probe *does* use devm_k?alloc, so perhaps you
were getting confused with that?

Steve

>  	return ret;
>  }
>  
> 


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

* Re: [PATCH] rqchip/stm32: Remove unneeded call to kfree
  2019-07-22 10:26 ` Steven Price
@ 2019-07-23 16:19   ` Hariprasad Kelam
  0 siblings, 0 replies; 3+ messages in thread
From: Hariprasad Kelam @ 2019-07-23 16:19 UTC (permalink / raw)
  To: Steven Price, Thomas Gleixner, Jason Cooper, Marc Zyngier,
	Maxime Coquelin, Alexandre Torgue, linux-kernel, linux-stm32,
	linux-arm-kernel

On Mon, Jul 22, 2019 at 11:26:09AM +0100, Steven Price wrote:
> On 19/07/2019 19:46, Hariprasad Kelam wrote:
> > Memory allocated by devm_ alloc will be freed upon device detachment. So
> > we may not require free memory.
> > 
> > Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.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);
> 
> In the commit this is based on these variables are not allocated using a
> devm_ alloc function:
> 
> $ git show e00f2fa | grep -A12 *stm32_exti_host_init
> > stm32_exti_host_data *stm32_exti_host_init(const struct stm32_exti_drv_data *dd,
> > 					   struct device_node *node)
> > {
> > 	struct stm32_exti_host_data *host_data;
> > 
> > 	host_data = kzalloc(sizeof(*host_data), GFP_KERNEL);
> > 	if (!host_data)
> > 		return NULL;
> > 
> > 	host_data->drv_data = dd;
> > 	host_data->chips_data = kcalloc(dd->bank_nr,
> > 					sizeof(struct stm32_exti_chip_data),
> > 					GFP_KERNEL);
> The function stm32_exti_probe *does* use devm_k?alloc, so perhaps you
> were getting confused with that?
> 
> Steve
>
  Yes thanks  for explanation. Please ignore this patch

  Thanks,
  Hariprasad k
> >  	return ret;
> >  }
> >  
> > 
> 

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

end of thread, other threads:[~2019-07-23 16:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-19 18:46 [PATCH] rqchip/stm32: Remove unneeded call to kfree Hariprasad Kelam
2019-07-22 10:26 ` Steven Price
2019-07-23 16:19   ` Hariprasad Kelam

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).