Skip to contentSkip to conversation

wm8350-core: fix wrong kfree in error path

PATCH Applied Axel Lin 3 participants 3 messages Aug 4, 2010 – Aug 5, 2010

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 wm8350-core: fix wrong kfree in error path

This patch includes below fixes:
1. fix wm8350_create_cache error path
make sure wm8350->reg_cache is freed in error path.
2. fix wm8350_device_init error path
no need to kfree(wm8350->reg_cache) in the case of goto out.

---
 drivers/mfd/wm8350-core.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/mfd/wm8350-core.c +4 -2
index b580748..e81cc31 100644
@@ -536,6 +536,7 @@ static int wm8350_create_cache(struct wm8350 *wm8350, int type, int mode)
 	}
 
 out:
+	kfree(wm8350->reg_cache);
 	return ret;
 }
 
@@ -700,7 +701,7 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
 
 	ret = wm8350_irq_init(wm8350, irq, pdata);
 	if (ret < 0)
-		goto err;
+		goto err_free;
 
 	if (wm8350->irq_base) {
 		ret = request_threaded_irq(wm8350->irq_base +
@@ -738,8 +739,9 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
 
 err_irq:
 	wm8350_irq_exit(wm8350);
-err:
+err_free:
 	kfree(wm8350->reg_cache);
+err:
 	return ret;
 }
 EXPORT_SYMBOL_GPL(wm8350_device_init);
Signature · 1 line
1.5.4.3
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Axel Lin

This patch includes below fixes:
1. fix wm8350_create_cache error path
make sure wm8350->reg_cache is freed in error path.
2. fix wm8350_device_init error path
no need to kfree(wm8350->reg_cache) in the case of goto out.

Please remember to always submit separate patches for separate issues, mixing things together makes review harder and means that if there's a problem with one part of what you've done the entire patch gets held up.

Applied
#2 lore raw
In reply to Axel Lin

Hi Axel,

Quoted 5 lines · Axel Lin

This patch includes below fixes:
1. fix wm8350_create_cache error path
make sure wm8350->reg_cache is freed in error path.
2. fix wm8350_device_init error path
no need to kfree(wm8350->reg_cache) in the case of goto out.

Applied, although as Mark pointed out, I'd have preferred 2 patches here.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/