From: Chris Diamand Date: Thu, 12 Jan 2017 14:57:41 +0000 (+0000) Subject: PM / devfreq: Don't delete sysfs group twice X-Git-Tag: accepted/tizen/4.0/unified/20170920.081531~68 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4b45ea5c64d27885087dff216513818e42868d0c;p=platform%2Fkernel%2Flinux-exynos.git PM / devfreq: Don't delete sysfs group twice The 'userspace' governor adds a sysfs entry, which is removed when the governor is changed, or the devfreq device is released. However, when the latter occurs via device_unregister(), device_del() is called first, which removes the sysfs entries recursively and deletes the kobject. This means we get an Oops when the governor calls sysfs_remove_group() on the deleted kobject. Fix this by only doing the call when kobj *hasn't* been kobject_del()'d. Note that we can't just remove the call to sysfs_remove_group() entirely - it's needed for when the governor is changed to one which doesn't need a sysfs entry. Signed-off-by: Chris Diamand Reviewed-by: Chanwoo Choi Signed-off-by: MyungJoo Ham --- diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c index 35de6e8..9db4d6f 100644 --- a/drivers/devfreq/governor_userspace.c +++ b/drivers/devfreq/governor_userspace.c @@ -112,7 +112,13 @@ out: static void userspace_exit(struct devfreq *devfreq) { - sysfs_remove_group(&devfreq->dev.kobj, &dev_attr_group); + /* + * Remove the sysfs entry, unless this is being called after + * device_del(), which should have done this already via kobject_del(). + */ + if (devfreq->dev.kobj.sd) + sysfs_remove_group(&devfreq->dev.kobj, &dev_attr_group); + kfree(devfreq->data); devfreq->data = NULL; }