---
 plugins/hfp_ag_bluez5.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index 245de21..6451be4 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -123,6 +123,14 @@ static DBusMessage *profile_new_connection(DBusConnection 
*conn,
 
        ofono_emulator_register(em, fd);
 
+       if (ofono_emulator_create_card(em, 0) < 0) {
+               close(fd);
+               ofono_emulator_remove(em);
+               return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
+                                               ".Rejected",
+                                               "Not enough resources");
+       }
+
        fd_dup = dup(fd);
        io = g_io_channel_unix_new(fd_dup);
        g_io_add_watch_full(io, G_PRIORITY_DEFAULT, G_IO_HUP, io_hup_cb,
-- 
1.7.9.5

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

Reply via email to