This patch fix an unusual scenario, service_level_connection() fails if
GIOChannel or GAtChat memory allocation fails.
---
 plugins/hfp_hf_bluez5.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 871c720..08c6fed 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -358,10 +358,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);
        bt_bacpy(&hfp->src, &src.rc_bdaddr);
-- 
1.7.11.7

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to