Fix a memleak
[platform/core/system/peripheral-bus.git] / src / util / peripheral_privilege.c
index 335f9b9..443964b 100644 (file)
@@ -82,21 +82,23 @@ int peripheral_privilege_check(GDBusMethodInvocation *invocation, GDBusConnectio
 
        if (!session || !client || !user) {
                _E("Failed to get client info");
-               return -1;
+               ret = -1;
+               goto cleanup;
        }
 
        ret = cynara_check(__cynara, client, session, user, PERIPHERAL_PRIVILEGE);
        if (ret != CYNARA_API_ACCESS_ALLOWED) {
                _E("Failed to check privilege");
-               g_free(session);
-               g_free(client);
-               g_free(user);
-               return -EACCES;
+               ret = -EACCES;
+               goto cleanup;
        }
 
+       ret = 0;
+
+cleanup:
        g_free(session);
        g_free(client);
        g_free(user);
 
-       return 0;
+       return ret;
 }