summaryrefslogtreecommitdiffstats
path: root/common/glib-helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/glib-helper.c')
-rw-r--r--common/glib-helper.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/common/glib-helper.c b/common/glib-helper.c
index f4d3f9d4..5938e654 100644
--- a/common/glib-helper.c
+++ b/common/glib-helper.c
@@ -154,11 +154,13 @@ int bt_discover_services(const bdaddr_t *src, const bdaddr_t *dst,
s = sdp_connect(src, dst, SDP_NON_BLOCKING);
if (!s)
- return -EIO;
+ return -errno;
- ctxt = g_malloc0(sizeof(struct search_context));
- if (!ctxt)
+ ctxt = g_try_malloc0(sizeof(struct search_context));
+ if (!ctxt) {
+ sdp_close(s);
return -ENOMEM;
+ }
bacpy(&ctxt->src, src);
bacpy(&ctxt->dst, dst);