summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaurav Babu <saurav.babu@samsung.com>2016-07-11 11:27:02 +0530
committerPatrik Flykt <patrik.flykt@linux.intel.com>2016-07-13 14:29:02 +0300
commit00e7aaf5a4f6c9d6ce1f17ea4687e4edd17a1045 (patch)
tree7b8fc2e38167f050b07057dafa3368872582c1bb
parent81eb5014f6b094562ae4245921e4ea18f7a5c6a7 (diff)
downloadconnman-00e7aaf5a4f6c9d6ce1f17ea4687e4edd17a1045.tar.gz
client: Fix memory leak while enabling tethering
"tether" was allocated memory in tether_set_ssid() but was never freed while enabling tethering. This is the valgrind report of the issue ==14814== 12 bytes in 1 blocks are definitely lost in loss record 19 of 140 ==14814== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==14814== by 0x50CA610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) ==14814== by 0x408989: cmd_tether (in /usr/local/bin/connmanctl) ==14814== by 0x409BEA: __connmanctl_commands (in /usr/local/bin/connmanctl) ==14814== by 0x40A0AA: rl_handler (in /usr/local/bin/connmanctl) ==14814== by 0x53AE63D: rl_callback_read_char (in /lib/x86_64-linux-gnu/libreadline.so.6.3) ==14814== by 0x40A16D: input_handler (in /usr/local/bin/connmanctl) ==14814== by 0x50C4CE4: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) ==14814== by 0x50C5047: g_main_context_iterate.isra.24 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) ==14814== by 0x50C5309: g_main_loop_run (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) ==14814== by 0x40A54A: __connmanctl_input_init (in /usr/local/bin/connmanctl) ==14814== by 0x55EBEC4: (below main) (libc-start.c:287)
-rw-r--r--client/commands.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/client/commands.c b/client/commands.c
index eec200f3..d7f59efb 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -523,8 +523,13 @@ struct tether_properties {
static int tether_update(struct tether_properties *tether)
{
- if (tether->ssid_result == 0 && tether->passphrase_result == 0)
- return tether_set("wifi", tether->set_tethering);
+ int ret;
+
+ if (tether->ssid_result == 0 && tether->passphrase_result == 0) {
+ ret = tether_set("wifi", tether->set_tethering);
+ g_free(tether);
+ return ret;
+ }
if (tether->ssid_result != -EINPROGRESS &&
tether->passphrase_result != -EINPROGRESS) {