If parsing udata fails, 'chain' has to be freed before returning to caller. Fixes: 702ac2b72c0e8 ("src: add comment support for chains") Signed-off-by: Phil Sutter <phil@xxxxxx> --- src/netlink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/netlink.c b/src/netlink.c index 41cce3379ca50..1bbdf98bd2ee2 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -599,6 +599,7 @@ struct chain *netlink_delinearize_chain(struct netlink_ctx *ctx, udata = nftnl_chain_get_data(nlc, NFTNL_CHAIN_USERDATA, &ulen); if (nftnl_udata_parse(udata, ulen, chain_parse_udata_cb, ud) < 0) { netlink_io_error(ctx, NULL, "Cannot parse userdata"); + chain_free(chain); return NULL; } if (ud[NFTNL_UDATA_CHAIN_COMMENT]) -- 2.31.1