diff --git a/client/gatt.c b/client/gatt.c
index 3aaa7a9..6c76039 100644
--- a/client/gatt.c
+++ b/client/gatt.c
struct msghdr msg;
int ret;
+ ret = io_get_fd(io);
+ if (ret < 0)
+ return ret;
+
memset(&msg, 0, sizeof(msg));
msg.msg_iov = iov;
msg.msg_iovlen = iovlen;
- ret = sendmsg(io_get_fd(io), &msg, MSG_NOSIGNAL);
+ ret = sendmsg(ret, &msg, MSG_NOSIGNAL);
if (ret < 0) {
ret = -errno;
bt_shell_printf("sendmsg: %s", strerror(-ret));
if (io != notify_io.io && !chrc)
return true;
+ if (fd < 0) {
+ bt_shell_printf("recvmsg: %s", strerror(-fd));
+ return false;
+ }
+
iov.iov_base = buf;
iov.iov_len = sizeof(buf);