if (filter_index != HCI_DEV_NONE)
attach_index_filter(data->fd, filter_index);
- mainloop_add_fd(data->fd, EPOLLIN, data_callback, data, free_data);
+ if (mainloop_add_fd(data->fd, EPOLLIN, data_callback,
+ data, free_data) < 0) {
+ close(data->fd);
+ free(data);
+ return -1;
+ };
return 0;
}
data->channel = HCI_CHANNEL_MONITOR;
data->fd = nfd;
- mainloop_add_fd(data->fd, EPOLLIN, client_callback, data, free_data);
+ if (mainloop_add_fd(data->fd, EPOLLIN, client_callback,
+ data, free_data) < 0) {
+ close(data->fd);
+ free(data);
+ }
}
static int server_fd = -1;
data->channel = HCI_CHANNEL_MONITOR;
data->fd = fd;
- mainloop_add_fd(data->fd, EPOLLIN, tty_callback, data, free_data);
+ if (mainloop_add_fd(data->fd, EPOLLIN, tty_callback,
+ data, free_data) < 0) {
+ close(data->fd);
+ free(data);
+ return -1;
+ }
return 0;
}
return;
}
- mainloop_add_fd(data->fd, EPOLLIN, device_callback, data, free_data);
+ if (mainloop_add_fd(data->fd, EPOLLIN, device_callback,
+ data, free_data) < 0) {
+ close(data->fd);
+ free(data);
+ }
}
static void device_info(int fd, uint16_t index, uint8_t *type, uint8_t *bus,
return -1;
}
- mainloop_add_fd(data->fd, EPOLLIN, stack_internal_callback,
- data, free_data);
+ if (mainloop_add_fd(data->fd, EPOLLIN, stack_internal_callback,
+ data, free_data) < 0) {
+ close(data->fd);
+ free(data);
+ return -1;
+ }
return 0;
}