summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2013-04-02 11:51:53 +0200
committerThomas Graf <tgraf@suug.ch>2013-04-02 11:51:53 +0200
commitdf66b0f267af636848d7f0301d3f5863c58fb313 (patch)
treee355abe611ba735d1ce832e90fa94017aaf28ba3
parent18152ca91622e11f8ac1e2b9806c134d616fd1fe (diff)
genl: Fix cb reference leak in genl_ctrl_probe_by_name()
nl_socket_get_cb() bumps the cb reference counter Signed-off-by: Thomas Graf <tgraf@suug.ch>
-rw-r--r--lib/genl/ctrl.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/genl/ctrl.c b/lib/genl/ctrl.c
index c6db742..ce07f1d 100644
--- a/lib/genl/ctrl.c
+++ b/lib/genl/ctrl.c
@@ -239,7 +239,7 @@ static struct genl_family *genl_ctrl_probe_by_name(struct nl_sock *sk,
{
struct nl_msg *msg;
struct genl_family *ret;
- struct nl_cb *cb;
+ struct nl_cb *cb, *orig;
int rc;
ret = genl_family_alloc();
@@ -252,7 +252,12 @@ static struct genl_family *genl_ctrl_probe_by_name(struct nl_sock *sk,
if (!msg)
goto out_fam_free;
- if (!(cb = nl_cb_clone(nl_socket_get_cb(sk))))
+ if (!(orig = nl_socket_get_cb(sk)))
+ goto out_msg_free;
+
+ cb = nl_cb_clone(orig);
+ nl_cb_put(orig);
+ if (!cb)
goto out_msg_free;
if (!genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, GENL_ID_CTRL,