Skip to content

Commit 0741f55

Browse files
ubizjakummakynes
authored andcommitted
netfilter: nf_tables: Fix percpu address space issues in nf_tables_api.c
Compiling nf_tables_api.c results in several sparse warnings: nf_tables_api.c:2077:31: warning: incorrect type in return expression (different address spaces) nf_tables_api.c:2080:31: warning: incorrect type in return expression (different address spaces) nf_tables_api.c:2084:31: warning: incorrect type in return expression (different address spaces) nf_tables_api.c:2740:23: warning: incorrect type in assignment (different address spaces) nf_tables_api.c:2752:38: warning: incorrect type in assignment (different address spaces) nf_tables_api.c:2798:21: warning: incorrect type in argument 1 (different address spaces) Use {ERR_PTR,IS_ERR,PTR_ERR}_PCPU() macros when crossing between generic and percpu address spaces and add __percpu annotation to *stats pointer to fix these warnings. Found by GCC's named address space checks. There were no changes in the resulting object files. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 6c959fd commit 0741f55

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,14 +2082,14 @@ static struct nft_stats __percpu *nft_stats_alloc(const struct nlattr *attr)
20822082
err = nla_parse_nested_deprecated(tb, NFTA_COUNTER_MAX, attr,
20832083
nft_counter_policy, NULL);
20842084
if (err < 0)
2085-
return ERR_PTR(err);
2085+
return ERR_PTR_PCPU(err);
20862086

20872087
if (!tb[NFTA_COUNTER_BYTES] || !tb[NFTA_COUNTER_PACKETS])
2088-
return ERR_PTR(-EINVAL);
2088+
return ERR_PTR_PCPU(-EINVAL);
20892089

20902090
newstats = netdev_alloc_pcpu_stats(struct nft_stats);
20912091
if (newstats == NULL)
2092-
return ERR_PTR(-ENOMEM);
2092+
return ERR_PTR_PCPU(-ENOMEM);
20932093

20942094
/* Restore old counters on this cpu, no problem. Per-cpu statistics
20952095
* are not exposed to userspace.
@@ -2533,10 +2533,10 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
25332533

25342534
if (nla[NFTA_CHAIN_COUNTERS]) {
25352535
stats = nft_stats_alloc(nla[NFTA_CHAIN_COUNTERS]);
2536-
if (IS_ERR(stats)) {
2536+
if (IS_ERR_PCPU(stats)) {
25372537
nft_chain_release_hook(&hook);
25382538
kfree(basechain);
2539-
return PTR_ERR(stats);
2539+
return PTR_ERR_PCPU(stats);
25402540
}
25412541
rcu_assign_pointer(basechain->stats, stats);
25422542
}
@@ -2650,7 +2650,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
26502650
struct nft_table *table = ctx->table;
26512651
struct nft_chain *chain = ctx->chain;
26522652
struct nft_chain_hook hook = {};
2653-
struct nft_stats *stats = NULL;
2653+
struct nft_stats __percpu *stats = NULL;
26542654
struct nft_hook *h, *next;
26552655
struct nf_hook_ops *ops;
26562656
struct nft_trans *trans;
@@ -2746,8 +2746,8 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
27462746
}
27472747

27482748
stats = nft_stats_alloc(nla[NFTA_CHAIN_COUNTERS]);
2749-
if (IS_ERR(stats)) {
2750-
err = PTR_ERR(stats);
2749+
if (IS_ERR_PCPU(stats)) {
2750+
err = PTR_ERR_PCPU(stats);
27512751
goto err_hooks;
27522752
}
27532753
}

0 commit comments

Comments
 (0)