diff options
author | Thomas Graf <tgraf@suug.ch> | 2013-04-02 09:51:53 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2013-04-02 09:51:53 (GMT) |
commit | df66b0f267af636848d7f0301d3f5863c58fb313 (patch) | |
tree | e355abe611ba735d1ce832e90fa94017aaf28ba3 /lib/genl | |
parent | 18152ca91622e11f8ac1e2b9806c134d616fd1fe (diff) | |
download | libnl-df66b0f267af636848d7f0301d3f5863c58fb313.zip libnl-df66b0f267af636848d7f0301d3f5863c58fb313.tar.gz libnl-df66b0f267af636848d7f0301d3f5863c58fb313.tar.bz2 |
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>
Diffstat (limited to 'lib/genl')
-rw-r--r-- | lib/genl/ctrl.c | 9 |
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, |