[Skiboot] [PATCH 10/13] libstb/stb.c: free cvc allocated memory
Claudio Carvalho
cclaudio at linux.vnet.ibm.com
Thu Aug 31 16:45:58 AEST 2017
We no longer need to hold the cleanup cvc hook because the cvc driver
initialization is now done in a single place.
This adds cvc_free() and also calls it to free the cvc allocated
memory before the skiroot kernel is executed. Additionally, this also
removes the cvc .name attribute.
Signed-off-by: Claudio Carvalho <cclaudio at linux.vnet.ibm.com>
---
libstb/stb.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/libstb/stb.c b/libstb/stb.c
index ee5771a..3bc41c6 100644
--- a/libstb/stb.c
+++ b/libstb/stb.c
@@ -33,14 +33,12 @@
//#define STB_DEBUG
struct container_verification_code {
- const char *name;
uint64_t verify_addr;
uint64_t sha512_addr;
void (*sha512)(void *func_addr, const uint8_t *data, size_t len,
uint8_t *digest);
int (*verify)(void *func_addr, const char *name, void *container,
const void *hw_key_hash, size_t hw_key_hash_size);
- void (*cleanup)(void);
};
static struct container_verification_code *c1vc = NULL;
@@ -104,6 +102,18 @@ static void sb_enforce(void)
abort();
}
+static void cvc_free(void)
+{
+ if (c1vc) {
+ free(c1vc);
+ c1vc = NULL;
+ }
+ if (secure_rom_mem) {
+ free(secure_rom_mem);
+ secure_rom_mem = NULL;
+ }
+}
+
static int c1vc_mbedtls_init(struct dt_node *node)
{
const char* hash_algo;
@@ -131,8 +141,6 @@ static int c1vc_mbedtls_init(struct dt_node *node)
c1vc->sha512 = c1vc_mbedtls_sha512;
c1vc->verify_addr = 0;
c1vc->verify = c1vc_mbedtls_verify;
- c1vc->cleanup = c1vc_mbedtls_cleanup;
- c1vc->name = "c1vc_mbedtls";
prlog(PR_INFO, "STB: 'ibm,secureboot-v1-softrom' initialized\n");
return 0;
@@ -189,9 +197,6 @@ static int c1vc_rom_init(struct dt_node *parent)
c1vc->verify_addr = (uint64_t) secure_rom_mem + SECURE_ROM_VERIFY_OFFSET;
c1vc->verify = c1vc_verify;
- c1vc->cleanup = c1vc_cleanup;
- c1vc->name = "c1vc";
-
prlog(PR_INFO, "STB: 'ibm,secureboot-v1' initialized\n");
return 0;
}
@@ -299,6 +304,7 @@ int stb_final(void)
tpm_cleanup();
secure_mode = false;
trusted_mode = false;
+ cvc_free();
return (failed) ? STB_MEASURE_FAILED : 0;
}
--
2.7.4
More information about the Skiboot
mailing list