{
GIOChannel *io = NULL;
GError *gerr = NULL;
+ int fd;
- io = g_io_channel_unix_new(bt_att_get_fd(att));
+ fd = bt_att_get_fd(att);
+ if (fd < 0) {
+ error("failed to get fd");
+ return false;
+ }
+
+ io = g_io_channel_unix_new(fd);
if (!io)
return false;
if (!filename) {
warn("Unable to get ccc storage path for device");
g_free(data);
+ g_key_file_free(key_file);
return enc_error_resp(ATT_OP_WRITE_REQ, handle,
ATT_ECODE_WRITE_NOT_PERM,
pdu, len);
/* Get the CCC value */
value = g_key_file_get_string(key_file, group, "Value", NULL);
- if (!value)
+ if (!value) {
+ g_free(filename);
+ g_key_file_free(key_file);
return 0;
+ }
sscanf(value, "%hX", &cccval);