hfp_hf_bluez5: Fix missing fd close
authorClaudio Takahasi <claudio.takahasi@openbossa.org>
Tue, 29 Jan 2013 20:38:40 +0000 (17:38 -0300)
committerDenis Kenzior <denkenz@gmail.com>
Tue, 29 Jan 2013 21:58:39 +0000 (15:58 -0600)
This patch fix an unusual scenario, service_level_connection() fails if
GIOChannel or GAtChat memory allocation fails.

plugins/hfp_hf_bluez5.c

index c4a3f32f1f4b6f600939e00b879418d885d11665..2aabdd2e3de0ca23a3b095ac5399b10164f2ebde 100644 (file)
@@ -323,10 +323,12 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
        }
 
        err = service_level_connection(modem, fd, HFP_VERSION_LATEST);
-       if (err < 0 && err != -EINPROGRESS)
+       if (err < 0 && err != -EINPROGRESS) {
+               close(fd);
                return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
                                        ".Rejected",
                                        "Not enough resources");
+       }
 
        hfp = ofono_modem_get_data(modem);
        hfp->msg = dbus_message_ref(msg);