android/bluetooth: Fix memory leak in store_link_key

If loading key file from file failed free key file. This fix following:

490 (40 direct, 450 indirect) bytes in 1 blocks are definitely lost in
    loss record 122 of 126
   at 0x4028B4C: malloc (vg_replace_malloc.c:291)
   by 0x40A25B2: g_malloc (in /lib/i386-linux-gnu/
    libglib-2.0.so.0.3800.2)
   by 0x40B8DB1: g_slice_alloc (in /lib/i386-linux-gnu/
    libglib-2.0.so.0.3800.2)
   by 0x40B92DC: g_slice_alloc0 (in /lib/i386-linux-gnu/
    libglib-2.0.so.0.3800.2)
   by 0x40946BB: g_key_file_new (in /lib/i386-linux-gnu/
    libglib-2.0.so.0.3800.2)
   by 0x8054A84: new_link_key_callback (bluetooth.c:563)
   by 0x804FB44: notify_handler (mgmt.c:278)
   by 0x804F357: queue_foreach (queue.c:186)
   by 0x804FE6C: can_read_data (mgmt.c:290)
   by 0x804ED12: read_callback (io-glib.c:168)
   by 0x40E0CF4: ??? (in /lib/i386-linux-gnu/libglib-2.0.so.0.3800.2)
   by 0x409CAED: g_main_context_dispatch (in /lib/i386-linux-gnu/
    libglib-2.0.so.0.3800.2)
This commit is contained in:
Szymon Janc 2014-02-22 21:51:30 +01:00
parent 3df773a3ad
commit c6d09297cd

View File

@ -562,8 +562,10 @@ static void store_link_key(const bdaddr_t *dst, const uint8_t *key,
key_file = g_key_file_new();
if (!g_key_file_load_from_file(key_file, DEVICES_FILE, 0, NULL))
if (!g_key_file_load_from_file(key_file, DEVICES_FILE, 0, NULL)) {
g_key_file_free(key_file);
return;
}
ba2str(dst, addr);