]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/netlabel/netlabel_cipso_v4.c
[CELL] spufs: fix decr_status meanings
[linux-2.6-omap-h63xx.git] / net / netlabel / netlabel_cipso_v4.c
index 4afc75f9e377b7bb167749b8a51ec50589182cf9..c060e3f991f10ab9d13bb0c5aa4c043d17c2a66e 100644 (file)
@@ -41,6 +41,7 @@
 
 #include "netlabel_user.h"
 #include "netlabel_cipso_v4.h"
+#include "netlabel_mgmt.h"
 
 /* Argument struct for cipso_v4_doi_walk() */
 struct netlbl_cipsov4_doiwalk_arg {
@@ -59,7 +60,7 @@ static struct genl_family netlbl_cipsov4_gnl_family = {
 };
 
 /* NetLabel Netlink attribute policy */
-static struct nla_policy netlbl_cipsov4_genl_policy[NLBL_CIPSOV4_A_MAX + 1] = {
+static const struct nla_policy netlbl_cipsov4_genl_policy[NLBL_CIPSOV4_A_MAX + 1] = {
        [NLBL_CIPSOV4_A_DOI] = { .type = NLA_U32 },
        [NLBL_CIPSOV4_A_MTYPE] = { .type = NLA_U32 },
        [NLBL_CIPSOV4_A_TAG] = { .type = NLA_U8 },
@@ -130,12 +131,12 @@ static int netlbl_cipsov4_add_common(struct genl_info *info,
 
        nla_for_each_nested(nla, info->attrs[NLBL_CIPSOV4_A_TAGLST], nla_rem)
                if (nla->nla_type == NLBL_CIPSOV4_A_TAG) {
-                       if (iter > CIPSO_V4_TAG_MAXCNT)
+                       if (iter >= CIPSO_V4_TAG_MAXCNT)
                                return -EINVAL;
                        doi_def->tags[iter++] = nla_get_u8(nla);
                }
-       if (iter < CIPSO_V4_TAG_MAXCNT)
-               doi_def->tags[iter] = CIPSO_V4_TAG_INVALID;
+       while (iter < CIPSO_V4_TAG_MAXCNT)
+               doi_def->tags[iter++] = CIPSO_V4_TAG_INVALID;
 
        return 0;
 }
@@ -292,7 +293,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info)
                                        }
                        }
                doi_def->map.std->cat.local = kcalloc(
-                                             doi_def->map.std->cat.local_size,
+                                             doi_def->map.std->cat.local_size,
                                              sizeof(u32),
                                              GFP_KERNEL);
                if (doi_def->map.std->cat.local == NULL) {
@@ -300,7 +301,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info)
                        goto add_std_failure;
                }
                doi_def->map.std->cat.cipso = kcalloc(
-                                             doi_def->map.std->cat.cipso_size,
+                                             doi_def->map.std->cat.cipso_size,
                                              sizeof(u32),
                                              GFP_KERNEL);
                if (doi_def->map.std->cat.cipso == NULL) {
@@ -325,10 +326,10 @@ static int netlbl_cipsov4_add_std(struct genl_info *info)
                                if (cat_loc == NULL || cat_rem == NULL)
                                        goto add_std_failure;
                                doi_def->map.std->cat.local[
-                                                       nla_get_u32(cat_loc)] =
+                                                       nla_get_u32(cat_loc)] =
                                        nla_get_u32(cat_rem);
                                doi_def->map.std->cat.cipso[
-                                                       nla_get_u32(cat_rem)] =
+                                                       nla_get_u32(cat_rem)] =
                                        nla_get_u32(cat_loc);
                        }
        }
@@ -419,6 +420,8 @@ static int netlbl_cipsov4_add(struct sk_buff *skb, struct genl_info *info)
                ret_val = netlbl_cipsov4_add_pass(info);
                break;
        }
+       if (ret_val == 0)
+               netlbl_mgmt_protocount_inc();
 
        audit_buf = netlbl_audit_start_common(AUDIT_MAC_CIPSOV4_ADD,
                                              &audit_info);
@@ -694,6 +697,8 @@ static int netlbl_cipsov4_remove(struct sk_buff *skb, struct genl_info *info)
        ret_val = cipso_v4_doi_remove(doi,
                                      &audit_info,
                                      netlbl_cipsov4_doi_free);
+       if (ret_val == 0)
+               netlbl_mgmt_protocount_dec();
 
        audit_buf = netlbl_audit_start_common(AUDIT_MAC_CIPSOV4_DEL,
                                              &audit_info);