aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs
diff options
context:
space:
mode:
authorNick Dyer <nick.dyer@itdev.co.uk>2013-06-07 10:45:13 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-07 19:05:50 -0400
commitfc60bb8339b66183f40ea9a001538c958f6d2c9e (patch)
treeed6e5bea8971fb25642606872c98b1f3f619abfe /fs/sysfs
parentd6c8aa3906d5d0e4012b9811d6e0928dc7b4cbaf (diff)
sysfs_notify is only possible on file attributes
If sysfs_notify is called on a binary attribute, bad things can happen, so prevent it. Note, no in-kernel usage of this is currently present, but in the future, it's good to be safe. Changes in V2: - Also ignore sysfs_notify on dirs, links - Use WARN_ON rather than silently failing - Compiled and tested (huge apologies about first submission) Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs')
-rw-r--r--fs/sysfs/file.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 602f56db0442..d2bb7ed8fa74 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -449,10 +449,12 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
449 449
450 spin_lock_irqsave(&sysfs_open_dirent_lock, flags); 450 spin_lock_irqsave(&sysfs_open_dirent_lock, flags);
451 451
452 od = sd->s_attr.open; 452 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
453 if (od) { 453 od = sd->s_attr.open;
454 atomic_inc(&od->event); 454 if (od) {
455 wake_up_interruptible(&od->poll); 455 atomic_inc(&od->event);
456 wake_up_interruptible(&od->poll);
457 }
456 } 458 }
457 459
458 spin_unlock_irqrestore(&sysfs_open_dirent_lock, flags); 460 spin_unlock_irqrestore(&sysfs_open_dirent_lock, flags);