]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
genl: Fix cb reference leak in genl_ctrl_probe_by_name()
authorThomas Graf <tgraf@suug.ch>
Tue, 2 Apr 2013 09:51:53 +0000 (11:51 +0200)
committerThomas Graf <tgraf@suug.ch>
Tue, 2 Apr 2013 09:51:53 +0000 (11:51 +0200)
nl_socket_get_cb() bumps the cb reference counter

Signed-off-by: Thomas Graf <tgraf@suug.ch>
lib/genl/ctrl.c

index c6db7423c3933e8cf80b6457068275b73e57bdab..ce07f1d41a0ca0e1fc0853e3e09b8a9bdb55fd75 100644 (file)
@@ -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,