Commit fc60bb83 authored by Nick Dyer's avatar Nick Dyer Committed by Greg Kroah-Hartman
Browse files

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: default avatarNick Dyer <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent d6c8aa39
...@@ -449,10 +449,12 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd) ...@@ -449,10 +449,12 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
spin_lock_irqsave(&sysfs_open_dirent_lock, flags); spin_lock_irqsave(&sysfs_open_dirent_lock, flags);
od = sd->; if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
if (od) { od = sd->;
atomic_inc(&od->event); if (od) {
wake_up_interruptible(&od->poll); atomic_inc(&od->event);
} }
spin_unlock_irqrestore(&sysfs_open_dirent_lock, flags); spin_unlock_irqrestore(&sysfs_open_dirent_lock, flags);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment