Skip to content

Commit

Permalink
PM / devfreq: Don't delete sysfs group twice
Browse files Browse the repository at this point in the history
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 <chris.diamand@arm.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
  • Loading branch information
Chris Diamand authored and MyungJoo Ham committed Jan 31, 2017
1 parent 566cf87 commit 924b911
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/devfreq/governor_userspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ static int userspace_init(struct devfreq *devfreq)

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;
}
Expand Down

0 comments on commit 924b911

Please sign in to comment.