workqueue: use put_device() instead of kfree()
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Tue, 6 Mar 2018 10:05:43 +0000 (15:35 +0530)
committerTejun Heo <tj@kernel.org>
Tue, 13 Mar 2018 20:26:03 +0000 (13:26 -0700)
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@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/workqueue.c

index bb9a519cbf5093ece372daa532121f1511957999..ccd1080dd6e7108a9521a0d2ea6d1a9a52c6431c 100644 (file)
@@ -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;
        }