summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaurav Babu <saurav.babu@samsung.com>2018-06-05 12:57:31 +0530
committerSaurav Babu <saurav.babu@samsung.com>2018-06-11 11:29:04 +0000
commit1ccc890efb354343041512b2e25d673c1d00e235 (patch)
tree31f1c2cae0cfabc2297cf745c0fe36075ff0b5db
parent522b6f5340a56e3431cb5aa82fef864aa45a7a32 (diff)
downloadconnman-1ccc890efb354343041512b2e25d673c1d00e235.tar.gz
connman-1ccc890efb354343041512b2e25d673c1d00e235.tar.bz2
connman-1ccc890efb354343041512b2e25d673c1d00e235.zip
telephony: Fixed memory leak
Valgrind reported memory leak with below backtrace ==3471== 1,934 (80 direct, 1,854 indirect) bytes in 2 blocks are definitely lost in loss record 190 of 194 ==3471== at 0x484801C: calloc (vg_replace_malloc.c:711) ==3471== by 0x49D687B: dbus_malloc0 (dbus-memory.c:572) ==3471== by 0x49BB9A3: _dbus_pending_call_new_unlocked (dbus-pending-call.c:124) ==3471== by 0x4995963: dbus_connection_send_with_reply (dbus-connection.c:3449) ==3471== by 0x135D8D: __dbus_request.constprop.8 (telephony.c:396) ==3471== by 0x135E6D: __request_get_services (telephony.c:477) ==3471== by 0x136F19: __add_modem (telephony.c:802) ==3471== by 0x13732F: __response_get_modems (telephony.c:464) ==3471== by 0x498FABB: complete_pending_call_and_unlock (dbus-connection.c:2340) ==3471== by 0x49981BF: dbus_connection_dispatch (dbus-connection.c:4757) ==3471== by 0x18E815: message_dispatch (mainloop.c:72) ==3471== by 0x48BB8E7: g_main_dispatch (gmain.c:3234) ==3471== by 0x48BB8E7: g_main_context_dispatch (gmain.c:3887 When dbus response is received then we should unref memory allocated by libdbus Change-Id: I81c514506f0df42e537d63382b2eb2ebc51c58c8 Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
-rwxr-xr-xplugins/telephony.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/plugins/telephony.c b/plugins/telephony.c
index 2b4c5a4a..2954c183 100755
--- a/plugins/telephony.c
+++ b/plugins/telephony.c
@@ -390,8 +390,10 @@ static int __dbus_request(const char *path, const char *interface,
ok = dbus_message_append_args_valist(message, type, va);
va_end(va);
- if (!ok)
+ if (!ok) {
+ dbus_message_unref(message);
return -ENOMEM;
+ }
if (dbus_connection_send_with_reply(connection, message,
&call, TIMEOUT) == FALSE) {
@@ -489,10 +491,6 @@ static void __response_get_services(DBusPendingCall *call, void *user_data)
struct telephony_modem *modem;
modem = g_hash_table_lookup(modem_hash, path);
- if (modem == NULL)
- return;
- if (modem->device == NULL)
- return;
DBG("");
@@ -506,6 +504,9 @@ static void __response_get_services(DBusPendingCall *call, void *user_data)
goto done;
}
+ if (modem == NULL || modem->device == NULL)
+ goto done;
+
DBG("message signature (%s)", dbus_message_get_signature(reply));
if (dbus_message_iter_init(reply, &args) == FALSE)