Commit 51edb2ff authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso Committed by Jakub Kicinski

netfilter: nf_tables: typo NULL check in _clone() function

This should check for NULL in case memory allocation fails.
Reported-by: default avatarJulian Wiedmann <jwiedmann.dev@gmail.com>
Fixes: 3b9e2ea6 ("netfilter: nft_limit: move stateful fields out of expression data")
Fixes: 37f319f3 ("netfilter: nft_connlimit: move stateful fields out of expression data")
Fixes: 33a24de3 ("netfilter: nft_last: move stateful fields out of expression data")
Fixes: ed0a0c60 ("netfilter: nft_quota: move stateful fields out of expression data")
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Link: https://lore.kernel.org/r/20220110194817.53481-1-pablo@netfilter.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent fe8152b3
...@@ -206,7 +206,7 @@ static int nft_connlimit_clone(struct nft_expr *dst, const struct nft_expr *src) ...@@ -206,7 +206,7 @@ static int nft_connlimit_clone(struct nft_expr *dst, const struct nft_expr *src)
struct nft_connlimit *priv_src = nft_expr_priv(src); struct nft_connlimit *priv_src = nft_expr_priv(src);
priv_dst->list = kmalloc(sizeof(*priv_dst->list), GFP_ATOMIC); priv_dst->list = kmalloc(sizeof(*priv_dst->list), GFP_ATOMIC);
if (priv_dst->list) if (!priv_dst->list)
return -ENOMEM; return -ENOMEM;
nf_conncount_list_init(priv_dst->list); nf_conncount_list_init(priv_dst->list);
......
...@@ -106,7 +106,7 @@ static int nft_last_clone(struct nft_expr *dst, const struct nft_expr *src) ...@@ -106,7 +106,7 @@ static int nft_last_clone(struct nft_expr *dst, const struct nft_expr *src)
struct nft_last_priv *priv_dst = nft_expr_priv(dst); struct nft_last_priv *priv_dst = nft_expr_priv(dst);
priv_dst->last = kzalloc(sizeof(*priv_dst->last), GFP_ATOMIC); priv_dst->last = kzalloc(sizeof(*priv_dst->last), GFP_ATOMIC);
if (priv_dst->last) if (!priv_dst->last)
return -ENOMEM; return -ENOMEM;
return 0; return 0;
......
...@@ -145,7 +145,7 @@ static int nft_limit_clone(struct nft_limit_priv *priv_dst, ...@@ -145,7 +145,7 @@ static int nft_limit_clone(struct nft_limit_priv *priv_dst,
priv_dst->invert = priv_src->invert; priv_dst->invert = priv_src->invert;
priv_dst->limit = kmalloc(sizeof(*priv_dst->limit), GFP_ATOMIC); priv_dst->limit = kmalloc(sizeof(*priv_dst->limit), GFP_ATOMIC);
if (priv_dst->limit) if (!priv_dst->limit)
return -ENOMEM; return -ENOMEM;
spin_lock_init(&priv_dst->limit->lock); spin_lock_init(&priv_dst->limit->lock);
......
...@@ -237,7 +237,7 @@ static int nft_quota_clone(struct nft_expr *dst, const struct nft_expr *src) ...@@ -237,7 +237,7 @@ static int nft_quota_clone(struct nft_expr *dst, const struct nft_expr *src)
struct nft_quota *priv_dst = nft_expr_priv(dst); struct nft_quota *priv_dst = nft_expr_priv(dst);
priv_dst->consumed = kmalloc(sizeof(*priv_dst->consumed), GFP_ATOMIC); priv_dst->consumed = kmalloc(sizeof(*priv_dst->consumed), GFP_ATOMIC);
if (priv_dst->consumed) if (!priv_dst->consumed)
return -ENOMEM; return -ENOMEM;
atomic64_set(priv_dst->consumed, 0); atomic64_set(priv_dst->consumed, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment