[PATCH] rtnl_link_af_unregister: fix locking

Nathan Lynch ntl at pobox.com
Mon Apr 29 17:29:46 EDT 2013


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.
---
 lib/route/link/api.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/route/link/api.c b/lib/route/link/api.c
index 352bb83..6d1e12f 100644
--- a/lib/route/link/api.c
+++ b/lib/route/link/api.c
@@ -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;
 }
-- 
1.8.1.4




More information about the libnl mailing list