Skip to content

Commit

Permalink
workqueue: use put_device() instead of kfree()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arvind Yadav authored and Tejun Heo committed Mar 13, 2018
1 parent fc6eabb commit 537f414
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 537f414

Please sign in to comment.