Skip to contentSkip to conversation

remove explicit devm_kfree

PATCH In review Arjun Sreedharan 2 participants 2 messages Aug 15, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove explicit devm_kfree

Memory allocated with devm_kzalloc() is freed automatically when device out of scope.

---
 drivers/input/misc/soc_button_array.c | 1 -
 1 file changed, 1 deletion(-)
drivers/input/misc/soc_button_array.c +0 -1
index 5a6334b..123e59f 100644
@@ -131,7 +131,6 @@ soc_button_device_create(struct pnp_dev *pdev,
 err_free_pdev:
 	platform_device_put(pd);
 err_free_mem:
-	devm_kfree(&pdev->dev, gpio_keys_pdata);
 	return ERR_PTR(error);
 }
 
Signature · 1 line
1.7.11.7
maintainer
#1 lore raw
Quoted 2 lines · Arjun Sreedharan

Memory allocated with devm_kzalloc() is freed automatically when device out of scope.

But in this case the device does not necessarily goes "out of scope" and we still want to release memory.

Thanks.

Quoted 21 lines
---
 drivers/input/misc/soc_button_array.c | 1 -
 1 file changed, 1 deletion(-)
drivers/input/misc/soc_button_array.c +0 -1
index 5a6334b..123e59f 100644
@@ -131,7 +131,6 @@ soc_button_device_create(struct pnp_dev *pdev,
 err_free_pdev:
 	platform_device_put(pd);
 err_free_mem:
-	devm_kfree(&pdev->dev, gpio_keys_pdata);
 	return ERR_PTR(error);
 }
 
Signature · 1 line
1.7.11.7
Signature · 1 line
Dmitry