Skip to content

Commit

Permalink
net: Fix bridgeing sysfs handling of rtnl_lock
Browse files Browse the repository at this point in the history
Holding rtnl_lock when we are unregistering the sysfs files can
deadlock if we unconditionally take rtnl_lock in a sysfs file.  So fix
it with the now familiar patter of: rtnl_trylock and syscall_restart()

Signed-off-by: Eric W. Biederman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ebiederm authored and davem330 committed May 19, 2009
1 parent 9b8adb5 commit af38f29
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion net/bridge/br_sysfs_br.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ static ssize_t store_stp_state(struct device *d,
if (endp == buf)
return -EINVAL;

rtnl_lock();
if (!rtnl_trylock())
return restart_syscall();
br_stp_set_enabled(br, val);
rtnl_unlock();

Expand Down
3 changes: 2 additions & 1 deletion net/bridge/br_sysfs_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ static ssize_t brport_store(struct kobject * kobj,

val = simple_strtoul(buf, &endp, 0);
if (endp != buf) {
rtnl_lock();
if (!rtnl_trylock())
return restart_syscall();
if (p->dev && p->br && brport_attr->store) {
spin_lock_bh(&p->br->lock);
ret = brport_attr->store(p, val);
Expand Down

0 comments on commit af38f29

Please sign in to comment.