Fix memory leak when parsing netlink messages into caches
The reference created by the parsers was never given back.
This commit is contained in:
parent
91c330aae5
commit
155ad439a4
14 changed files with 25 additions and 20 deletions
|
@ -114,7 +114,7 @@ static int result_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
|
|||
/* REAL HACK, fib_lookup doesn't support ACK nor does it
|
||||
* send a DONE message, enforce end of message stream
|
||||
* after just the first message */
|
||||
return NL_STOP;
|
||||
err = NL_STOP;
|
||||
|
||||
errout:
|
||||
flnl_result_put(res);
|
||||
|
|
|
@ -131,7 +131,7 @@ static int ctrl_msg_parser(struct nl_cache_ops *ops, struct genl_cmd *cmd,
|
|||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
return P_ACCEPT;
|
||||
err = P_ACCEPT;
|
||||
|
||||
errout:
|
||||
genl_family_put(family);
|
||||
|
|
|
@ -366,13 +366,15 @@ static int ct_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
|
|||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
return P_ACCEPT;
|
||||
err = P_ACCEPT;
|
||||
|
||||
errout_errno:
|
||||
err = nl_get_errno();
|
||||
errout:
|
||||
nfnl_ct_put(ct);
|
||||
return err;
|
||||
|
||||
errout_errno:
|
||||
err = nl_get_errno();
|
||||
goto errout;
|
||||
}
|
||||
|
||||
int nfnl_ct_dump_request(struct nl_handle *h)
|
||||
|
|
|
@ -174,13 +174,15 @@ static int log_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
|
|||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
return P_ACCEPT;
|
||||
err = P_ACCEPT;
|
||||
|
||||
errout_errno:
|
||||
err = nl_get_errno();
|
||||
errout:
|
||||
nfnl_log_put(log);
|
||||
return err;
|
||||
|
||||
errout_errno:
|
||||
err = nl_get_errno();
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -288,7 +288,7 @@ static int addr_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
|
|||
if (err < 0)
|
||||
goto errout_free;
|
||||
|
||||
return P_ACCEPT;
|
||||
err = P_ACCEPT;
|
||||
|
||||
errout_free:
|
||||
rtnl_addr_put(addr);
|
||||
|
|
|
@ -56,7 +56,7 @@ static int class_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
|
|||
if (err < 0)
|
||||
goto errout_free;
|
||||
|
||||
return P_ACCEPT;
|
||||
err = P_ACCEPT;
|
||||
|
||||
errout_free:
|
||||
rtnl_class_put(class);
|
||||
|
|
|
@ -67,7 +67,7 @@ static int cls_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
|
|||
if (err < 0)
|
||||
goto errout_free;
|
||||
|
||||
return P_ACCEPT;
|
||||
err = P_ACCEPT;
|
||||
|
||||
errout_free:
|
||||
rtnl_cls_put(cls);
|
||||
|
|
|
@ -327,7 +327,7 @@ static int link_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
|
|||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
return P_ACCEPT;
|
||||
err = P_ACCEPT;
|
||||
|
||||
errout:
|
||||
rtnl_link_put(link);
|
||||
|
|
|
@ -318,7 +318,7 @@ static int neigh_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
|
|||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
return P_ACCEPT;
|
||||
err = P_ACCEPT;
|
||||
|
||||
errout:
|
||||
rtnl_neigh_put(neigh);
|
||||
|
|
|
@ -220,7 +220,7 @@ static int neightbl_msg_parser(struct nl_cache_ops *ops,
|
|||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
return P_ACCEPT;
|
||||
err = P_ACCEPT;
|
||||
errout:
|
||||
rtnl_neightbl_put(ntbl);
|
||||
return err;
|
||||
|
|
|
@ -125,7 +125,7 @@ static int qdisc_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
|
|||
if (err < 0)
|
||||
goto errout_free;
|
||||
|
||||
return P_ACCEPT;
|
||||
err = P_ACCEPT;
|
||||
|
||||
errout_free:
|
||||
rtnl_qdisc_put(qdisc);
|
||||
|
|
|
@ -203,14 +203,15 @@ static int route_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
|
|||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
return P_ACCEPT;
|
||||
err = P_ACCEPT;
|
||||
|
||||
errout_errno:
|
||||
err = nl_get_errno();
|
||||
errout:
|
||||
rtnl_route_put(route);
|
||||
return err;
|
||||
|
||||
errout_errno:
|
||||
err = nl_get_errno();
|
||||
goto errout;
|
||||
}
|
||||
|
||||
static int route_request_update(struct nl_cache *c, struct nl_handle *h)
|
||||
|
|
|
@ -162,7 +162,7 @@ static int rule_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
|
|||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
return P_ACCEPT;
|
||||
err = P_ACCEPT;
|
||||
|
||||
errout:
|
||||
rtnl_rule_put(rule);
|
||||
|
|
|
@ -159,7 +159,7 @@ static struct nl_handle *__alloc_handle(struct nl_cb *cb)
|
|||
handle->h_local.nl_pid = generate_local_port();
|
||||
if (handle->h_local.nl_pid == UINT_MAX) {
|
||||
nl_handle_destroy(handle);
|
||||
nl_error(ENOBUFS, "Out of sequence numbers");
|
||||
nl_error(ENOBUFS, "Out of local ports");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue