summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-06-11 18:33:44 +0200
committerPhil Sutter <phil@nwl.cc>2021-06-14 13:31:07 +0200
commit47640634cff9932784a1a96836d6c5809cc8264d (patch)
tree48090a503a09b8b85ee1924ba3b68a2f0cc33cc3
parent04f7af9dd66d3a0f627f43bc4bf55bae9856efc8 (diff)
netlink: Avoid memleak in error path of netlink_delinearize_table()
If parsing udata fails, 'table' has to be freed before returning to caller. Fixes: c156232a530b3 ("src: add comment support when adding tables") Signed-off-by: Phil Sutter <phil@nwl.cc>
-rw-r--r--src/netlink.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/netlink.c b/src/netlink.c
index 1bbdf98b..be98bfb7 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -647,6 +647,7 @@ struct table *netlink_delinearize_table(struct netlink_ctx *ctx,
udata = nftnl_table_get_data(nlt, NFTNL_TABLE_USERDATA, &ulen);
if (nftnl_udata_parse(udata, ulen, table_parse_udata_cb, ud) < 0) {
netlink_io_error(ctx, NULL, "Cannot parse userdata");
+ table_free(table);
return NULL;
}
if (ud[NFTNL_UDATA_TABLE_COMMENT])