Skip to contentSkip to conversation

netfilter: nf_tables: check for NULL in nf_tables_newchain pcpu stats allocation

PATCH In review Sabrina Dubroca 2 participants 2 messages Oct 21, 2014 – Oct 22, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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")
---
 net/netfilter/nf_tables_api.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +2 -2
index 556a0dfa4abc..eb123676e1ef 100644
@@ -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
#1 lore raw
Quoted 1 line · Sabrina Dubroca

alloc_percpu returns NULL on failure, not a negative error code.

Good catch. Applied, thanks.