From 8f46baaa7ec6cd0851794020b31958e64679dd26 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 20 Feb 2013 10:31:42 +0200 Subject: [PATCH] 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: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 56536f4b0f6b..a7391a30cb29 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -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; } -- 2.45.2