netlink: fix potential deadlock in netlink_set_err()
[linux-2.6-microblaze.git] / net / netlink / af_netlink.c
index 3a1e0fd..5968b64 100644 (file)
@@ -1600,6 +1600,7 @@ out:
 int netlink_set_err(struct sock *ssk, u32 portid, u32 group, int code)
 {
        struct netlink_set_err_data info;
+       unsigned long flags;
        struct sock *sk;
        int ret = 0;
 
@@ -1609,12 +1610,12 @@ int netlink_set_err(struct sock *ssk, u32 portid, u32 group, int code)
        /* sk->sk_err wants a positive error value */
        info.code = -code;
 
-       read_lock(&nl_table_lock);
+       read_lock_irqsave(&nl_table_lock, flags);
 
        sk_for_each_bound(sk, &nl_table[ssk->sk_protocol].mc_list)
                ret += do_one_set_err(sk, &info);
 
-       read_unlock(&nl_table_lock);
+       read_unlock_irqrestore(&nl_table_lock, flags);
        return ret;
 }
 EXPORT_SYMBOL(netlink_set_err);