netlabel: Use genl_register_family_with_ops()
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>
Thu, 21 May 2009 10:34:05 +0000 (10:34 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 May 2009 23:50:24 +0000 (16:50 -0700)
Use genl_register_family_with_ops() instead of a copy. This fixes genetlink
family leak on error path.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netlabel/netlabel_cipso_v4.c
net/netlabel/netlabel_mgmt.c
net/netlabel/netlabel_unlabeled.c

index bf1ab1a6790d6102005d871359ab6ec211c619dc..e639298bc9c810a77961113b67a5078fee9bbd6f 100644 (file)
@@ -785,18 +785,6 @@ static struct genl_ops netlbl_cipsov4_ops[] = {
  */
 int __init netlbl_cipsov4_genl_init(void)
 {
-       int ret_val, i;
-
-       ret_val = genl_register_family(&netlbl_cipsov4_gnl_family);
-       if (ret_val != 0)
-               return ret_val;
-
-       for (i = 0; i < ARRAY_SIZE(netlbl_cipsov4_ops); i++) {
-               ret_val = genl_register_ops(&netlbl_cipsov4_gnl_family,
-                               &netlbl_cipsov4_ops[i]);
-               if (ret_val != 0)
-                       return ret_val;
-       }
-
-       return 0;
+       return genl_register_family_with_ops(&netlbl_cipsov4_gnl_family,
+               netlbl_cipsov4_ops, ARRAY_SIZE(netlbl_cipsov4_ops));
 }
index 1821c5d50fb8ec448374c04619c30eab07baa15f..8203623e65ad3c09f94869d6c8b9358d7f04c4bf 100644 (file)
@@ -779,18 +779,6 @@ static struct genl_ops netlbl_mgmt_genl_ops[] = {
  */
 int __init netlbl_mgmt_genl_init(void)
 {
-       int ret_val, i;
-
-       ret_val = genl_register_family(&netlbl_mgmt_gnl_family);
-       if (ret_val != 0)
-               return ret_val;
-
-       for (i = 0; i < ARRAY_SIZE(netlbl_mgmt_genl_ops); i++) {
-               ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
-                               &netlbl_mgmt_genl_ops[i]);
-               if (ret_val != 0)
-                       return ret_val;
-       }
-
-       return 0;
+       return genl_register_family_with_ops(&netlbl_mgmt_gnl_family,
+               netlbl_mgmt_genl_ops, ARRAY_SIZE(netlbl_mgmt_genl_ops));
 }
index f3c5c68c6848ee5daa1463c236936f0ff0264b2b..fb357f010189ec12b70de5b3677aea7169874e6c 100644 (file)
@@ -1478,20 +1478,8 @@ static struct genl_ops netlbl_unlabel_genl_ops[] = {
  */
 int __init netlbl_unlabel_genl_init(void)
 {
-       int ret_val, i;
-
-       ret_val = genl_register_family(&netlbl_unlabel_gnl_family);
-       if (ret_val != 0)
-               return ret_val;
-
-       for (i = 0; i < ARRAY_SIZE(netlbl_unlabel_genl_ops); i++) {
-               ret_val = genl_register_ops(&netlbl_unlabel_gnl_family,
-                               &netlbl_unlabel_genl_ops[i]);
-               if (ret_val != 0)
-                       return ret_val;
-       }
-
-       return 0;
+       return genl_register_family_with_ops(&netlbl_unlabel_gnl_family,
+               netlbl_unlabel_genl_ops, ARRAY_SIZE(netlbl_unlabel_genl_ops));
 }
 
 /*