On Wed, Sep 02, 2020 at 11:12:39AM +0200, Jose M. Guisado Gomez wrote: > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c > index 6ccce2a2e715..55111aefd3db 100644 > --- a/net/netfilter/nf_tables_api.c > +++ b/net/netfilter/nf_tables_api.c [...] > @@ -5954,32 +5957,48 @@ static int nf_tables_newobj(struct net *net, struct sock *nlsk, > obj->key.name = nla_strdup(nla[NFTA_OBJ_NAME], GFP_KERNEL); > if (!obj->key.name) { > err = -ENOMEM; > - goto err2; > + goto err_strdup; > + } > + > + if(nla[NFTA_OBJ_USERDATA]) { > + udlen = nla_len(nla[NFTA_OBJ_USERDATA]); > + obj->udata = kzalloc(udlen, GFP_KERNEL); > + if (obj->udata == NULL) > + goto err_userdata; > + } else { > + obj->udata = NULL; > + } > + > + if (udlen) { > + nla_memcpy(obj->udata, nla[NFTA_OBJ_USERDATA], udlen); > + obj->udlen = udlen; > } Probably simplify this? if(nla[NFTA_OBJ_USERDATA]) { udlen = nla_len(nla[NFTA_OBJ_USERDATA]); obj->udata = kzalloc(udlen, GFP_KERNEL); if (obj->udata == NULL) goto err_userdata; nla_memcpy(obj->udata, nla[NFTA_OBJ_USERDATA], udlen); obj->udlen = udlen; } obj is allocated via kzalloc(), so obj->udata is already guaranteed to be initialized to NULL, no need for the 'else' side of the branch. Thanks.