Add ima_free_policy function 49/28549/1
authorJanusz Kozerski <j.kozerski@samsung.com>
Thu, 15 May 2014 10:39:10 +0000 (12:39 +0200)
committerJanusz Kozerski <j.kozerski@samsung.com>
Thu, 9 Oct 2014 14:30:01 +0000 (16:30 +0200)
This function can be used to free the memory allocated by
ima_get_policy()

Change-Id: I8689c6c7525655bc69299a2f04b5e8a8db143057
Signed-off-by: Janusz Kozerski <j.kozerski@samsung.com>
src/imaevm.h
src/libimaevm.c

index 101dd21..b6e380e 100644 (file)
@@ -230,6 +230,8 @@ int ima_set_xattr(const char *path);
 int ima_get_xattr(const char *path, char **hash);
 int evm_set_xattr(const char *path, const char *evm);
 int evm_get_xattr(const char *path, char **hash);
+
 int ima_get_policy(char*** policy);
+int ima_free_policy(char **policy);
 
 #endif
index 3a79a26..5c0d69f 100644 (file)
@@ -1175,3 +1175,20 @@ out:
        free(policy_tmp);
        return ret_code;
 }
+
+int ima_free_policy(char **policy)
+{
+       int i = 0;
+
+       if (!policy)
+               return LIB_ERROR_INPUT_PARAM;
+
+       while (policy[i]) {
+               free(policy[i]);
+               policy[i] = NULL;
+               ++i;
+       }
+       free(policy);
+
+       return LIB_SUCCESS;
+}