Commit 7e8acbb6 authored by David S. Miller's avatar David S. Miller

Merge branch 'netlabel-next'

Markus Elfring says:

====================
netlabel: Deletion of a few unnecessary checks

Further update suggestions were taken into account after patches were applied
from static source code analysis.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 132d7bca 4de46d5e
...@@ -324,7 +324,6 @@ static int netlbl_cipsov4_add_std(struct genl_info *info, ...@@ -324,7 +324,6 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
return 0; return 0;
add_std_failure: add_std_failure:
if (doi_def)
cipso_v4_doi_free(doi_def); cipso_v4_doi_free(doi_def);
return ret_val; return ret_val;
} }
......
...@@ -93,23 +93,20 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ...@@ -93,23 +93,20 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
struct netlbl_audit *audit_info) struct netlbl_audit *audit_info)
{ {
int ret_val = -EINVAL; int ret_val = -EINVAL;
struct netlbl_dom_map *entry = NULL;
struct netlbl_domaddr_map *addrmap = NULL; struct netlbl_domaddr_map *addrmap = NULL;
struct cipso_v4_doi *cipsov4 = NULL; struct cipso_v4_doi *cipsov4 = NULL;
u32 tmp_val; u32 tmp_val;
struct netlbl_dom_map *entry = kzalloc(sizeof(*entry), GFP_KERNEL);
entry = kzalloc(sizeof(*entry), GFP_KERNEL); if (!entry)
if (entry == NULL) { return -ENOMEM;
ret_val = -ENOMEM;
goto add_failure;
}
entry->def.type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]); entry->def.type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
if (info->attrs[NLBL_MGMT_A_DOMAIN]) { if (info->attrs[NLBL_MGMT_A_DOMAIN]) {
size_t tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]); size_t tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]);
entry->domain = kmalloc(tmp_size, GFP_KERNEL); entry->domain = kmalloc(tmp_size, GFP_KERNEL);
if (entry->domain == NULL) { if (entry->domain == NULL) {
ret_val = -ENOMEM; ret_val = -ENOMEM;
goto add_failure; goto add_free_entry;
} }
nla_strlcpy(entry->domain, nla_strlcpy(entry->domain,
info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size); info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size);
...@@ -125,16 +122,16 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ...@@ -125,16 +122,16 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
break; break;
case NETLBL_NLTYPE_CIPSOV4: case NETLBL_NLTYPE_CIPSOV4:
if (!info->attrs[NLBL_MGMT_A_CV4DOI]) if (!info->attrs[NLBL_MGMT_A_CV4DOI])
goto add_failure; goto add_free_domain;
tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CV4DOI]); tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CV4DOI]);
cipsov4 = cipso_v4_doi_getdef(tmp_val); cipsov4 = cipso_v4_doi_getdef(tmp_val);
if (cipsov4 == NULL) if (cipsov4 == NULL)
goto add_failure; goto add_free_domain;
entry->def.cipso = cipsov4; entry->def.cipso = cipsov4;
break; break;
default: default:
goto add_failure; goto add_free_domain;
} }
if (info->attrs[NLBL_MGMT_A_IPV4ADDR]) { if (info->attrs[NLBL_MGMT_A_IPV4ADDR]) {
...@@ -145,7 +142,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ...@@ -145,7 +142,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL); addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
if (addrmap == NULL) { if (addrmap == NULL) {
ret_val = -ENOMEM; ret_val = -ENOMEM;
goto add_failure; goto add_doi_put_def;
} }
INIT_LIST_HEAD(&addrmap->list4); INIT_LIST_HEAD(&addrmap->list4);
INIT_LIST_HEAD(&addrmap->list6); INIT_LIST_HEAD(&addrmap->list6);
...@@ -153,12 +150,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ...@@ -153,12 +150,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
if (nla_len(info->attrs[NLBL_MGMT_A_IPV4ADDR]) != if (nla_len(info->attrs[NLBL_MGMT_A_IPV4ADDR]) !=
sizeof(struct in_addr)) { sizeof(struct in_addr)) {
ret_val = -EINVAL; ret_val = -EINVAL;
goto add_failure; goto add_free_addrmap;
} }
if (nla_len(info->attrs[NLBL_MGMT_A_IPV4MASK]) != if (nla_len(info->attrs[NLBL_MGMT_A_IPV4MASK]) !=
sizeof(struct in_addr)) { sizeof(struct in_addr)) {
ret_val = -EINVAL; ret_val = -EINVAL;
goto add_failure; goto add_free_addrmap;
} }
addr = nla_data(info->attrs[NLBL_MGMT_A_IPV4ADDR]); addr = nla_data(info->attrs[NLBL_MGMT_A_IPV4ADDR]);
mask = nla_data(info->attrs[NLBL_MGMT_A_IPV4MASK]); mask = nla_data(info->attrs[NLBL_MGMT_A_IPV4MASK]);
...@@ -166,7 +163,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ...@@ -166,7 +163,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
map = kzalloc(sizeof(*map), GFP_KERNEL); map = kzalloc(sizeof(*map), GFP_KERNEL);
if (map == NULL) { if (map == NULL) {
ret_val = -ENOMEM; ret_val = -ENOMEM;
goto add_failure; goto add_free_addrmap;
} }
map->list.addr = addr->s_addr & mask->s_addr; map->list.addr = addr->s_addr & mask->s_addr;
map->list.mask = mask->s_addr; map->list.mask = mask->s_addr;
...@@ -178,7 +175,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ...@@ -178,7 +175,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
ret_val = netlbl_af4list_add(&map->list, &addrmap->list4); ret_val = netlbl_af4list_add(&map->list, &addrmap->list4);
if (ret_val != 0) { if (ret_val != 0) {
kfree(map); kfree(map);
goto add_failure; goto add_free_addrmap;
} }
entry->def.type = NETLBL_NLTYPE_ADDRSELECT; entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
...@@ -192,7 +189,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ...@@ -192,7 +189,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL); addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
if (addrmap == NULL) { if (addrmap == NULL) {
ret_val = -ENOMEM; ret_val = -ENOMEM;
goto add_failure; goto add_doi_put_def;
} }
INIT_LIST_HEAD(&addrmap->list4); INIT_LIST_HEAD(&addrmap->list4);
INIT_LIST_HEAD(&addrmap->list6); INIT_LIST_HEAD(&addrmap->list6);
...@@ -200,12 +197,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ...@@ -200,12 +197,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
if (nla_len(info->attrs[NLBL_MGMT_A_IPV6ADDR]) != if (nla_len(info->attrs[NLBL_MGMT_A_IPV6ADDR]) !=
sizeof(struct in6_addr)) { sizeof(struct in6_addr)) {
ret_val = -EINVAL; ret_val = -EINVAL;
goto add_failure; goto add_free_addrmap;
} }
if (nla_len(info->attrs[NLBL_MGMT_A_IPV6MASK]) != if (nla_len(info->attrs[NLBL_MGMT_A_IPV6MASK]) !=
sizeof(struct in6_addr)) { sizeof(struct in6_addr)) {
ret_val = -EINVAL; ret_val = -EINVAL;
goto add_failure; goto add_free_addrmap;
} }
addr = nla_data(info->attrs[NLBL_MGMT_A_IPV6ADDR]); addr = nla_data(info->attrs[NLBL_MGMT_A_IPV6ADDR]);
mask = nla_data(info->attrs[NLBL_MGMT_A_IPV6MASK]); mask = nla_data(info->attrs[NLBL_MGMT_A_IPV6MASK]);
...@@ -213,7 +210,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ...@@ -213,7 +210,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
map = kzalloc(sizeof(*map), GFP_KERNEL); map = kzalloc(sizeof(*map), GFP_KERNEL);
if (map == NULL) { if (map == NULL) {
ret_val = -ENOMEM; ret_val = -ENOMEM;
goto add_failure; goto add_free_addrmap;
} }
map->list.addr = *addr; map->list.addr = *addr;
map->list.addr.s6_addr32[0] &= mask->s6_addr32[0]; map->list.addr.s6_addr32[0] &= mask->s6_addr32[0];
...@@ -227,7 +224,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ...@@ -227,7 +224,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
ret_val = netlbl_af6list_add(&map->list, &addrmap->list6); ret_val = netlbl_af6list_add(&map->list, &addrmap->list6);
if (ret_val != 0) { if (ret_val != 0) {
kfree(map); kfree(map);
goto add_failure; goto add_free_addrmap;
} }
entry->def.type = NETLBL_NLTYPE_ADDRSELECT; entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
...@@ -237,16 +234,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ...@@ -237,16 +234,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
ret_val = netlbl_domhsh_add(entry, audit_info); ret_val = netlbl_domhsh_add(entry, audit_info);
if (ret_val != 0) if (ret_val != 0)
goto add_failure; goto add_free_addrmap;
return 0; return 0;
add_failure: add_free_addrmap:
if (cipsov4) kfree(addrmap);
add_doi_put_def:
cipso_v4_doi_putdef(cipsov4); cipso_v4_doi_putdef(cipsov4);
if (entry) add_free_domain:
kfree(entry->domain); kfree(entry->domain);
kfree(addrmap); add_free_entry:
kfree(entry); kfree(entry);
return ret_val; return ret_val;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment