Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nft_redir: fix sparse warnings

>> net/netfilter/nft_redir.c:39:26: sparse: incorrect type in assignment (different base types)
net/netfilter/nft_redir.c:39:26: expected unsigned int [unsigned] [usertype] nla_be32
net/netfilter/nft_redir.c:39:26: got restricted __be32
>> net/netfilter/nft_redir.c:40:40: sparse: cast to restricted __be32
>> net/netfilter/nft_redir.c:40:40: sparse: cast to restricted __be32
>> net/netfilter/nft_redir.c:40:40: sparse: cast to restricted __be32
>> net/netfilter/nft_redir.c:40:40: sparse: cast to restricted __be32
>> net/netfilter/nft_redir.c:40:40: sparse: cast to restricted __be32
>> net/netfilter/nft_redir.c:40:40: sparse: cast to restricted __be32
>> net/netfilter/nft_redir.c:46:34: sparse: incorrect type in assignment (different base types)
net/netfilter/nft_redir.c:46:34: expected unsigned int [unsigned] [usertype] nla_be32
net/netfilter/nft_redir.c:46:34: got restricted __be32
>> net/netfilter/nft_redir.c:47:48: sparse: cast to restricted __be32
>> net/netfilter/nft_redir.c:47:48: sparse: cast to restricted __be32
>> net/netfilter/nft_redir.c:47:48: sparse: cast to restricted __be32
>> net/netfilter/nft_redir.c:47:48: sparse: cast to restricted __be32
>> net/netfilter/nft_redir.c:47:48: sparse: cast to restricted __be32
>> net/netfilter/nft_redir.c:47:48: sparse: cast to restricted __be32

Fixes: e9105f1 ("netfilter: nf_tables: add new expression nft_redir")
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

+6 -5
+6 -5
net/netfilter/nft_redir.c
··· 28 28 const struct nlattr * const tb[]) 29 29 { 30 30 struct nft_redir *priv = nft_expr_priv(expr); 31 - u32 nla_be32; 32 31 int err; 33 32 34 33 err = nft_chain_validate_dependency(ctx->chain, NFT_CHAIN_T_NAT); ··· 35 36 return err; 36 37 37 38 if (tb[NFTA_REDIR_REG_PROTO_MIN]) { 38 - nla_be32 = nla_get_be32(tb[NFTA_REDIR_REG_PROTO_MIN]); 39 - priv->sreg_proto_min = ntohl(nla_be32); 39 + priv->sreg_proto_min = 40 + ntohl(nla_get_be32(tb[NFTA_REDIR_REG_PROTO_MIN])); 41 + 40 42 err = nft_validate_input_register(priv->sreg_proto_min); 41 43 if (err < 0) 42 44 return err; 43 45 44 46 if (tb[NFTA_REDIR_REG_PROTO_MAX]) { 45 - nla_be32 = nla_get_be32(tb[NFTA_REDIR_REG_PROTO_MAX]); 46 - priv->sreg_proto_max = ntohl(nla_be32); 47 + priv->sreg_proto_max = 48 + ntohl(nla_get_be32(tb[NFTA_REDIR_REG_PROTO_MAX])); 49 + 47 50 err = nft_validate_input_register(priv->sreg_proto_max); 48 51 if (err < 0) 49 52 return err;