lkml.org 
[lkml]   [2014]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v2] Use kernfs_break_active_protection() for device online store callbacks
Hello,

On Fri, Apr 11, 2014 at 12:10:45PM +0800, Li Zhong wrote:
> @@ -439,6 +439,7 @@ static ssize_t online_store(struct device *dev, struct device_attribute *attr,
> {
> bool val;
> int ret;
> + struct kernfs_node *kn;
>
> ret = strtobool(buf, &val);
> if (ret < 0)
> @@ -448,7 +449,15 @@ static ssize_t online_store(struct device *dev, struct device_attribute *attr,
> if (ret)
> return ret;
>
> + kn = kernfs_find_and_get(dev->kobj.sd, attr->attr.name);

Wouldn't find_and_get need to be paired with put?

> + if (WARN_ON_ONCE(!kn))
> + goto out;
> +
> + kernfs_break_active_protection(kn);
> +
> ret = val ? device_online(dev) : device_offline(dev);

With active protection protection @dev may go away at any time. There
should be some protection / synchronization to prevent that, no?

> + kernfs_unbreak_active_protection(kn);
> +out:
> unlock_device_hotplug();
> return ret < 0 ? ret : count;
> }

Thanks.

--
tejun


\
 
 \ /
  Last update: 2014-04-11 12:41    [W:0.144 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site