]> granicus.if.org Git - libnl/commitdiff
rtnl_link_af_unregister: fix locking
authorNathan Lynch <ntl@pobox.com>
Mon, 29 Apr 2013 21:29:46 +0000 (16:29 -0500)
committerThomas Graf <tgraf@suug.ch>
Wed, 8 May 2013 11:48:24 +0000 (13:48 +0200)
rtnl_link_af_unregister() attempts to write-lock info_lock twice
instead of releasing it before returning.  It also will return with
info_lock write-locked if passed a NULL ops.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
lib/route/link/api.c

index 352bb839682626de455b8ce6feb75239330ce79a..6d1e12f88b2121158f65fc62d5bf2890c6d1e7b1 100644 (file)
@@ -326,7 +326,7 @@ int rtnl_link_af_unregister(struct rtnl_link_af_ops *ops)
        int err = -NLE_INVAL;
 
        if (!ops)
-               goto errout;
+               return err;
 
        nl_write_lock(&info_lock);
        if (!af_ops[ops->ao_family]) {
@@ -345,7 +345,7 @@ int rtnl_link_af_unregister(struct rtnl_link_af_ops *ops)
                ops->ao_family);
 
 errout:
-       nl_write_lock(&info_lock);
+       nl_write_unlock(&info_lock);
 
        return err;
 }