Skip to contentSkip to conversation

rqchip/stm32: Remove unneeded call to kfree

PATCH Superseded Hariprasad Kelam 2 participants 3 messages Jul 19, 2019 – Jul 23, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rqchip/stm32: Remove unneeded call to kfree

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

---
 drivers/irqchip/irq-stm32-exti.c | 2 --
 1 file changed, 2 deletions(-)
drivers/irqchip/irq-stm32-exti.c +0 -2
index e00f2fa..46ec0af 100644
@@ -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.7.4
#1 lore raw
Quoted 13 lines · Hariprasad Kelam

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

---
 drivers/irqchip/irq-stm32-exti.c | 2 --
 1 file changed, 2 deletions(-)
drivers/irqchip/irq-stm32-exti.c +0 -0
index e00f2fa..46ec0af 100644

drivers/irqchip/irq-stm32-exti.c static int __init stm32_exti_init(const struct stm32_exti_drv_data *drv_data, · line 783

Quoted 5 lines
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);

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
Quoted 5 lines
drivers/irqchip/irq-stm32-exti.c +0 -0
 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;
Quoted 8 lines
	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

Quoted 4 lines

return ret;
}

#2 lore raw
Quoted 33 lines · Steven Price
Quoted 13 lines · Hariprasad Kelam

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

---
 drivers/irqchip/irq-stm32-exti.c | 2 --
 1 file changed, 2 deletions(-)
drivers/irqchip/irq-stm32-exti.c +0 -0
index e00f2fa..46ec0af 100644

drivers/irqchip/irq-stm32-exti.c static int __init stm32_exti_init(const struct stm32_exti_drv_data *drv_data, · line 783

Quoted 5 lines
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);

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
Quoted 9 lines
drivers/irqchip/irq-stm32-exti.c +0 -0
 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;
Quoted 9 lines
Quoted 4 lines
	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

Quoted 5 lines
Quoted 4 lines

return ret;
}