diff options
author | Evan Huus <eapache@gmail.com> | 2015-07-05 11:32:44 -0400 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2015-07-05 17:30:25 +0000 |
commit | cfe7dc8bab00b80478418416de5354996fea3d3b (patch) | |
tree | b076192c13eac312aa43a57f6fb543f14ca79726 /caputils/ws80211_utils.c | |
parent | c00e4697e2003349afdc56cb4d3a853fac63fcbe (diff) |
80211 utils: free nl messages after use
Valgrind picked this up as a very large memory leak on systems with libnl,
since the GUI polls this code regularly and was leaking several nl messages
each time.
Change-Id: Ie6b32e094d90183a16fb187adea430c4b43c208c
Reviewed-on: https://code.wireshark.org/review/9502
Petri-Dish: Evan Huus <eapache@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'caputils/ws80211_utils.c')
-rw-r--r-- | caputils/ws80211_utils.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/caputils/ws80211_utils.c b/caputils/ws80211_utils.c index 5b1b5338f5..590edc47d9 100644 --- a/caputils/ws80211_utils.c +++ b/caputils/ws80211_utils.c @@ -228,6 +228,7 @@ static int ws80211_get_protocol_features(int* features) { struct nl_msg *msg; struct nl_cb *cb; + int ret; msg = nlmsg_alloc(); if (!msg) { @@ -242,7 +243,9 @@ static int ws80211_get_protocol_features(int* features) nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, get_features_handler, features); - return nl80211_do_cmd(msg, cb); + ret = nl80211_do_cmd(msg, cb); + nlmsg_free(msg); + return ret; } #endif /* HAVE_NL80211_SPLIT_WIPHY_DUMP */ @@ -402,6 +405,7 @@ static int ws80211_get_phys(GArray *interfaces) struct nliface_cookie cookie; struct nl_msg *msg; struct nl_cb *cb; + int ret; msg = nlmsg_alloc(); if (!msg) { fprintf(stderr, "failed to allocate netlink message\n"); @@ -422,10 +426,13 @@ static int ws80211_get_phys(GArray *interfaces) #endif /* #ifdef HAVE_NL80211_SPLIT_WIPHY_DUMP */ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, get_phys_handler, &cookie); - return nl80211_do_cmd(msg, cb); + ret = nl80211_do_cmd(msg, cb); + nlmsg_free(msg); + return ret; #ifdef HAVE_NL80211_SPLIT_WIPHY_DUMP nla_put_failure: + nlmsg_free(msg); fprintf(stderr, "building message failed\n"); return -1; #endif /* HAVE_NL80211_SPLIT_WIPHY_DUMP */ @@ -532,15 +539,19 @@ static int __ws80211_get_iface_info(const char *name, struct __iface_info *iface nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, get_iface_info_handler, iface_info); - if (nl80211_do_cmd(msg, cb)) + if (nl80211_do_cmd(msg, cb)) { + nlmsg_free(msg); return -1; + } /* Old kernels can't get the current freq via netlink. Try WEXT too :( */ if (iface_info->pub->current_freq == -1) iface_info->pub->current_freq = get_freq_wext(name); + nlmsg_free(msg); return 0; nla_put_failure: + nlmsg_free(msg); fprintf(stderr, "building message failed\n"); return -1; } |