OSDN Git Service

android/hidhost: Shutdown ctrl_io channel if intr_io fails
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Thu, 28 Nov 2013 14:38:03 +0000 (16:38 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 29 Nov 2013 08:29:55 +0000 (10:29 +0200)
This fix possible memory leak.

android/hidhost.c

index 50ac50d..44310ed 100644 (file)
@@ -1215,8 +1215,12 @@ bool bt_hid_register(const bdaddr_t *addr)
                                BT_IO_OPT_INVALID);
        if (!intr_io) {
                error("Failed to listen on intr channel: %s", err->message);
-               g_io_channel_unref(ctrl_io);
                g_error_free(err);
+
+               g_io_channel_shutdown(ctrl_io, TRUE, NULL);
+               g_io_channel_unref(ctrl_io);
+               ctrl_io = NULL;
+
                return false;
        }