netfilter: nf_tables: check for NULL in nf_tables_newchain pcpu stats allocation
Subsystems (3)
PATCH 1/1 netfilter: nf_tables: check for NULL in nf_tables_newchain pcpu stats allocation
alloc_percpu returns NULL on failure, not a negative error code.
Fixes ff3cd7b3c922 ("netfilter: nf_tables: refactor chain statistic routines")
Signed-off-by Sabrina Dubroca <[email protected]>
--- net/netfilter/nf_tables_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +2 -2
@@ -1328,10 +1328,10 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb, basechain->stats = stats; }else { stats = netdev_alloc_pcpu_stats(struct nft_stats); -if (IS_ERR (stats)) { +if (stats ==NULL ) {module_put (type->owner);kfree (basechain); -return PTR_ERR (stats); +return -ENOMEM ; }rcu_assign_pointer (basechain->stats, stats); }
Signature · 1 line
2.1.2
Pablo Neira Ayuso
maintainerQuoted 1 line · Sabrina Dubroca
alloc_percpureturns NULL on failure, not a negative error code.
Good catch. Applied, thanks.