[BlueZ PATCH 4/9] plugins/admin: Fix unchecked return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tedd Ho-Jeong An <tedd.an@xxxxxxxxx>

This patch fixes the unchecked return value(CWE-252) issues reported by
the Coverity.
---
 plugins/admin.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/plugins/admin.c b/plugins/admin.c
index 7b7190a06..a8e7d2cd7 100644
--- a/plugins/admin.c
+++ b/plugins/admin.c
@@ -247,6 +247,7 @@ failed:
 static void store_policy_settings(struct btd_admin_policy *admin_policy)
 {
 	GKeyFile *key_file = NULL;
+	GError *gerr = NULL;
 	char *filename = ADMIN_POLICY_STORAGE;
 	char *key_file_data = NULL;
 	char **uuid_strs = NULL;
@@ -274,7 +275,12 @@ static void store_policy_settings(struct btd_admin_policy *admin_policy)
 	}
 
 	key_file_data = g_key_file_to_data(key_file, &length, NULL);
-	g_file_set_contents(ADMIN_POLICY_STORAGE, key_file_data, length, NULL);
+	if (!g_file_set_contents(ADMIN_POLICY_STORAGE, key_file_data, length,
+								&gerr)) {
+		error("Unable set contents for %s: (%s)", ADMIN_POLICY_STORAGE,
+								gerr->message);
+		g_error_free(gerr);
+	}
 
 	g_free(key_file_data);
 	free_uuid_strings(uuid_strs, num_uuids);
@@ -335,6 +341,7 @@ failed:
 static void load_policy_settings(struct btd_admin_policy *admin_policy)
 {
 	GKeyFile *key_file;
+	GError *gerr = NULL;
 	char *filename = ADMIN_POLICY_STORAGE;
 	struct stat st;
 
@@ -343,7 +350,11 @@ static void load_policy_settings(struct btd_admin_policy *admin_policy)
 
 	key_file = g_key_file_new();
 
-	g_key_file_load_from_file(key_file, filename, 0, NULL);
+	if (!g_key_file_load_from_file(key_file, filename, 0, &gerr)) {
+		error("Unable to load key file from %s: (%s)", filename,
+								gerr->message);
+		g_error_free(gerr);
+	}
 
 	key_file_load_service_allowlist(key_file, admin_policy);
 
-- 
2.25.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux