On 21/8/20 19:21, Pablo Neira Ayuso wrote:
if (nla[NFTA_TABLE_USERDATA]) { udlen = nla_len(nla[NFTA_TABLE_USERDATA]); table->udata = kzalloc(udlen, GFP_KERNEL); if (table->udata == NULL) goto err_table_udata; nla_memcpy(table->udata, nla[NFTA_TABLE_USERDATA], udlen); table->udlen = udlen; } Probably this simplification instead? kzalloc() zeroes the table object, so table->udata is NULL and ->udlen is zero.
I see. The reason why I didn't simplify at first was because when using other nf_tables_new* functions with userdata support as reference (like newset or newrule), these are checking for userdata length obtained via nla_len before calling nla_memcpy.