Skip to content

Commit

Permalink
base: core: WARN() about bogus permissions on device attributes
Browse files Browse the repository at this point in the history
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: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Felipe Balbi authored and Greg Kroah-Hartman committed Mar 15, 2013
1 parent be871b7 commit 8f46baa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 8f46baa

Please sign in to comment.