netlabel: Fix some sparse warnings

Fix a few sparse warnings.  One dealt with a RCU lock being held on error,
another dealt with an improper type caused by a signed/unsigned mixup while
the rest appeared to be caused by using rcu_dereference() in a
list_for_each_entry_rcu() call.  The latter probably isn't a big deal, but
I derive a certain pleasure from knowing that the net/netlabel is nice and
clean.

Thanks to James Morris for pointing out the issues and demonstrating how
to run sparse.

Signed-off-by: Paul Moore <paul.moore@hp.com>
This commit is contained in:
Paul Moore 2008-10-10 10:16:29 -04:00
Родитель 3fa8749e58
Коммит 561967010e
3 изменённых файлов: 14 добавлений и 14 удалений

Просмотреть файл

@ -491,7 +491,7 @@ list_start:
doi_def = cipso_v4_doi_getdef(doi); doi_def = cipso_v4_doi_getdef(doi);
if (doi_def == NULL) { if (doi_def == NULL) {
ret_val = -EINVAL; ret_val = -EINVAL;
goto list_failure; goto list_failure_lock;
} }
ret_val = nla_put_u32(ans_skb, NLBL_CIPSOV4_A_MTYPE, doi_def->type); ret_val = nla_put_u32(ans_skb, NLBL_CIPSOV4_A_MTYPE, doi_def->type);
@ -655,7 +655,7 @@ static int netlbl_cipsov4_listall(struct sk_buff *skb,
struct netlink_callback *cb) struct netlink_callback *cb)
{ {
struct netlbl_cipsov4_doiwalk_arg cb_arg; struct netlbl_cipsov4_doiwalk_arg cb_arg;
int doi_skip = cb->args[0]; u32 doi_skip = cb->args[0];
cb_arg.nl_cb = cb; cb_arg.nl_cb = cb;
cb_arg.skb = skb; cb_arg.skb = skb;

Просмотреть файл

@ -115,13 +115,13 @@ static u32 netlbl_domhsh_hash(const char *key)
static struct netlbl_dom_map *netlbl_domhsh_search(const char *domain) static struct netlbl_dom_map *netlbl_domhsh_search(const char *domain)
{ {
u32 bkt; u32 bkt;
struct list_head *bkt_list;
struct netlbl_dom_map *iter; struct netlbl_dom_map *iter;
if (domain != NULL) { if (domain != NULL) {
bkt = netlbl_domhsh_hash(domain); bkt = netlbl_domhsh_hash(domain);
list_for_each_entry_rcu(iter, bkt_list = &rcu_dereference(netlbl_domhsh)->tbl[bkt];
&rcu_dereference(netlbl_domhsh)->tbl[bkt], list_for_each_entry_rcu(iter, bkt_list, list)
list)
if (iter->valid && strcmp(iter->domain, domain) == 0) if (iter->valid && strcmp(iter->domain, domain) == 0)
return iter; return iter;
} }
@ -410,6 +410,7 @@ int netlbl_domhsh_walk(u32 *skip_bkt,
{ {
int ret_val = -ENOENT; int ret_val = -ENOENT;
u32 iter_bkt; u32 iter_bkt;
struct list_head *iter_list;
struct netlbl_dom_map *iter_entry; struct netlbl_dom_map *iter_entry;
u32 chain_cnt = 0; u32 chain_cnt = 0;
@ -417,9 +418,8 @@ int netlbl_domhsh_walk(u32 *skip_bkt,
for (iter_bkt = *skip_bkt; for (iter_bkt = *skip_bkt;
iter_bkt < rcu_dereference(netlbl_domhsh)->size; iter_bkt < rcu_dereference(netlbl_domhsh)->size;
iter_bkt++, chain_cnt = 0) { iter_bkt++, chain_cnt = 0) {
list_for_each_entry_rcu(iter_entry, iter_list = &rcu_dereference(netlbl_domhsh)->tbl[iter_bkt];
&rcu_dereference(netlbl_domhsh)->tbl[iter_bkt], list_for_each_entry_rcu(iter_entry, iter_list, list)
list)
if (iter_entry->valid) { if (iter_entry->valid) {
if (chain_cnt++ < *skip_chain) if (chain_cnt++ < *skip_chain)
continue; continue;

Просмотреть файл

@ -381,12 +381,12 @@ static struct netlbl_unlhsh_addr6 *netlbl_unlhsh_search_addr6(
static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface(int ifindex) static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface(int ifindex)
{ {
u32 bkt; u32 bkt;
struct list_head *bkt_list;
struct netlbl_unlhsh_iface *iter; struct netlbl_unlhsh_iface *iter;
bkt = netlbl_unlhsh_hash(ifindex); bkt = netlbl_unlhsh_hash(ifindex);
list_for_each_entry_rcu(iter, bkt_list = &rcu_dereference(netlbl_unlhsh)->tbl[bkt];
&rcu_dereference(netlbl_unlhsh)->tbl[bkt], list_for_each_entry_rcu(iter, bkt_list, list)
list)
if (iter->valid && iter->ifindex == ifindex) if (iter->valid && iter->ifindex == ifindex)
return iter; return iter;
@ -1427,6 +1427,7 @@ static int netlbl_unlabel_staticlist(struct sk_buff *skb,
struct netlbl_unlhsh_iface *iface; struct netlbl_unlhsh_iface *iface;
struct netlbl_unlhsh_addr4 *addr4; struct netlbl_unlhsh_addr4 *addr4;
struct netlbl_unlhsh_addr6 *addr6; struct netlbl_unlhsh_addr6 *addr6;
struct list_head *iter_list;
cb_arg.nl_cb = cb; cb_arg.nl_cb = cb;
cb_arg.skb = skb; cb_arg.skb = skb;
@ -1436,9 +1437,8 @@ static int netlbl_unlabel_staticlist(struct sk_buff *skb,
for (iter_bkt = skip_bkt; for (iter_bkt = skip_bkt;
iter_bkt < rcu_dereference(netlbl_unlhsh)->size; iter_bkt < rcu_dereference(netlbl_unlhsh)->size;
iter_bkt++, iter_chain = 0, iter_addr4 = 0, iter_addr6 = 0) { iter_bkt++, iter_chain = 0, iter_addr4 = 0, iter_addr6 = 0) {
list_for_each_entry_rcu(iface, iter_list = &rcu_dereference(netlbl_unlhsh)->tbl[iter_bkt];
&rcu_dereference(netlbl_unlhsh)->tbl[iter_bkt], list_for_each_entry_rcu(iface, iter_list, list) {
list) {
if (!iface->valid || if (!iface->valid ||
iter_chain++ < skip_chain) iter_chain++ < skip_chain)
continue; continue;