From 3ffc0deb76894a792550d79eb437c94ad0677794 Mon Sep 17 00:00:00 2001 From: Hyuk Lee Date: Tue, 20 Mar 2018 13:58:21 +0900 Subject: [PATCH] Fix the coverity issue Change-Id: I984810e507f435e45108c0816d169e8447336716 Signed-off-by: Hyuk Lee --- obexd/plugins/messages-tizen.c | 2 +- profiles/audio/avdtp.c | 2 ++ profiles/proximity/immalert.c | 9 ++++++++- src/attrib-server.c | 6 +++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/obexd/plugins/messages-tizen.c b/obexd/plugins/messages-tizen.c index cb4116a..4ad3125 100644 --- a/obexd/plugins/messages-tizen.c +++ b/obexd/plugins/messages-tizen.c @@ -152,7 +152,7 @@ static gboolean is_time_in_period(char *ref_time, char *period) guint64 time_val; char *start; - char *end = NULL; + char *end; char temp[20]; diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index f60cb02..05c4c6c 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -1020,6 +1020,8 @@ static gboolean send_sprd_a2dp_qos(const bdaddr_t *dst, gboolean qos_high) qos_setup_cp cp; dd = hci_open_dev(0); + if (dd < 0) + return FALSE; cr = g_malloc0(sizeof(*cr) + sizeof(struct hci_conn_info)); diff --git a/profiles/proximity/immalert.c b/profiles/proximity/immalert.c index 1032ccc..92ca44a 100644 --- a/profiles/proximity/immalert.c +++ b/profiles/proximity/immalert.c @@ -82,8 +82,15 @@ static bool get_dest_info(struct bt_att *att, bdaddr_t *dst, uint8_t *dst_type) { 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; diff --git a/src/attrib-server.c b/src/attrib-server.c index 3bcc228..10b4a71 100755 --- a/src/attrib-server.c +++ b/src/attrib-server.c @@ -987,6 +987,7 @@ static uint16_t write_value(struct gatt_channel *channel, uint16_t handle, 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); @@ -1772,8 +1773,11 @@ static uint8_t attrib_get_ccc_info(struct btd_device *device, uint16_t handle) /* 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); -- 2.7.4