Skip to contentSkip to conversation

PM / devfreq: fix double kfree

PATCH MyungJoo Ham 1 participant 1 message Oct 2, 2015

lore
Share & tools
lore
#0 lore raw
Quoted 5 lines

When device_register() fails, kfree(devfreq) is called already in devfreq_dev_release(), hence there is no need to call kfree(devfreq) in err_dev again.

Thank you for pointing out that put_device() will eventually call kfree anyway.

Cheers,
MyungJoo

Quoted 27 lines
---
 drivers/devfreq/devfreq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/devfreq/devfreq.c +1 -2
index 3927ed9..9b352da 100644
@@ -492,7 +492,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
 	if (err) {
 		put_device(&devfreq->dev);
 		mutex_unlock(&devfreq->lock);
-		goto err_dev;
+		goto err_out;
 	}
 
 	mutex_unlock(&devfreq->lock);
@@ -518,7 +518,6 @@ struct devfreq *devfreq_add_device(struct device *dev,
 err_init:
 	list_del(&devfreq->node);
 	device_unregister(&devfreq->dev);
-err_dev:
 	kfree(devfreq);
 err_out:
 	return ERR_PTR(err);
Signature · 1 line
2.5.0