genetlink: Optimize genl_register_family()
[linux-2.6.git] / net / netlink / genetlink.c
index 44ff3f3810faa6c94e15c9b5f6b40312cf1c1182..ddfdb7d2e02bc0ddb9d5ea16efca211941053989 100644 (file)
@@ -374,11 +374,6 @@ int genl_register_family(struct genl_family *family)
                goto errout_locked;
        }
 
-       if (genl_family_find_byid(family->id)) {
-               err = -EEXIST;
-               goto errout_locked;
-       }
-
        if (family->id == GENL_ID_GENERATE) {
                u16 newid = genl_generate_id();
 
@@ -388,6 +383,9 @@ int genl_register_family(struct genl_family *family)
                }
 
                family->id = newid;
+       } else if (genl_family_find_byid(family->id)) {
+               err = -EEXIST;
+               goto errout_locked;
        }
 
        if (family->maxattr) {