diff options
author | Will Deacon <will@kernel.org> | 2019-12-17 14:20:25 +0000 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2020-04-15 21:36:41 +0100 |
commit | 514cc55b01eb7f34f9d1d4518f81e42a633c784e (patch) | |
tree | c8822a85072facd5d8e0be2306b139eef6d37501 /net/netfilter/core.c | |
parent | 5429ef62bcf360aae06740cbe065be01e5cfb6fc (diff) | |
download | linux-514cc55b01eb7f34f9d1d4518f81e42a633c784e.tar.gz linux-514cc55b01eb7f34f9d1d4518f81e42a633c784e.tar.bz2 linux-514cc55b01eb7f34f9d1d4518f81e42a633c784e.zip |
netfilter: Avoid assigning 'const' pointer to non-const pointer
nf_remove_net_hook() uses WRITE_ONCE() to assign a 'const' pointer to a
'non-const' pointer. Cleanups to the implementation of WRITE_ONCE() mean
that this will give rise to a compiler warning, just like a plain old
assignment would do:
| In file included from ./include/linux/export.h:43,
| from ./include/linux/linkage.h:7,
| from ./include/linux/kernel.h:8,
| from net/netfilter/core.c:9:
| net/netfilter/core.c: In function ‘nf_remove_net_hook’:
| ./include/linux/compiler.h:216:30: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
| *(volatile typeof(x) *)&(x) = (val); \
| ^
| net/netfilter/core.c:379:3: note: in expansion of macro ‘WRITE_ONCE’
| WRITE_ONCE(orig_ops[i], &dummy_ops);
| ^~~~~~~~~~
Follow the pattern used elsewhere in this file and add a cast to 'void *'
to squash the warning.
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jozsef Kadlecsik <kadlec@netfilter.org>
Cc: Florian Westphal <fw@strlen.de>
Cc: "David S. Miller" <davem@davemloft.net>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Diffstat (limited to 'net/netfilter/core.c')
-rw-r--r-- | net/netfilter/core.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/netfilter/core.c b/net/netfilter/core.c index 78f046ec506f..3ac7c8c1548d 100644 --- a/net/netfilter/core.c +++ b/net/netfilter/core.c @@ -376,7 +376,7 @@ static bool nf_remove_net_hook(struct nf_hook_entries *old, if (orig_ops[i] != unreg) continue; WRITE_ONCE(old->hooks[i].hook, accept_all); - WRITE_ONCE(orig_ops[i], &dummy_ops); + WRITE_ONCE(orig_ops[i], (void *)&dummy_ops); return true; } |