From: Felipe Balbi <balbi@ti.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Felipe Balbi <balbi@ti.com>
Subject: [PATCH] base: core: WARN() about bogus permissions on device attributes
Date: Wed, 20 Feb 2013 10:31:42 +0200 [thread overview]
Message-ID: <1361349102-15061-1-git-send-email-balbi@ti.com> (raw)
In-Reply-To: <20130220050122.GD2869@kroah.com>
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>
---
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 a235085..14e6a92 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;
}
--
1.8.1.rc1.5.g7e0651a
prev parent reply other threads:[~2013-02-20 8:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-18 19:09 [PATCH 1/2] base: memory: fix soft/hard_offline_page permissions Felipe Balbi
2013-02-18 19:09 ` [BONUS PATCH 2/2] base: core: WARN() about bogus permissions on device attributes Felipe Balbi
2013-02-18 19:17 ` Greg KH
2013-02-18 19:20 ` Felipe Balbi
2013-02-19 9:59 ` Felipe Balbi
2013-02-20 5:01 ` Greg KH
2013-02-20 8:31 ` Felipe Balbi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1361349102-15061-1-git-send-email-balbi@ti.com \
--to=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®