提交 8f46baaa 编写于 作者: F Felipe Balbi 提交者: Greg Kroah-Hartman

base: core: WARN() about bogus permissions on device attributes

Whenever a struct device_attribute is registered
with mismatched permissions - read permission without
a show routine or write permission without store
routine - we will issue a big warning so we catch
those early enough.
Signed-off-by: NFelipe Balbi <balbi@ti.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 be871b7e
......@@ -563,8 +563,15 @@ int device_create_file(struct device *dev,
const struct device_attribute *attr)
{
int error = 0;
if (dev)
if (dev) {
WARN(((attr->attr.mode & S_IWUGO) && !attr->store),
"Write permission without 'store'\n");
WARN(((attr->attr.mode & S_IRUGO) && !attr->show),
"Read permission without 'show'\n");
error = sysfs_create_file(&dev->kobj, &attr->attr);
}
return error;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册