[PATCH] workqueue: use put_device() instead of kfee()

From: Arvind Yadav
Date: Tue Mar 06 2018 - 05:01:56 EST


Never directly free @dev after calling device_register(), even
if it returned an error! Always use put_device() to give up the
reference initialized in this function instead.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@xxxxxxxxx>
---
kernel/workqueue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index bb9a519..ccd1080 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5337,7 +5337,7 @@ int workqueue_sysfs_register(struct workqueue_struct *wq)

ret = device_register(&wq_dev->dev);
if (ret) {
- kfree(wq_dev);
+ put_device(&wq_dev->dev);
wq->wq_dev = NULL;
return ret;
}
--
1.9.1