summaryrefslogtreecommitdiffstats
path: root/src/netlink.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-06-11 18:32:13 +0200
committerPhil Sutter <phil@nwl.cc>2021-06-14 13:31:07 +0200
commit04f7af9dd66d3a0f627f43bc4bf55bae9856efc8 (patch)
tree4580493268e65d901064da9d6a27bd8f3622261a /src/netlink.c
parentaccd7a346fd19f1ffc503b3f681323abf1157c1a (diff)
netlink: Avoid memleak in error path of netlink_delinearize_chain()
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@nwl.cc>
Diffstat (limited to 'src/netlink.c')
-rw-r--r--src/netlink.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/netlink.c b/src/netlink.c
index 41cce337..1bbdf98b 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])