From: Hosgor, Tolga (IOT DS EU TR MTS) <[email protected]>

bgenv_init() may be called multiple times during the operation of ebg
library. This causes devpath and mountpoint to be leaked.

Signed-off-by: Hosgor, Tolga (IOT DS EU TR MTS) <[email protected]>
---
 This is what we went with due to the lack of time to properly
 understand source and introduce _destroy counterpart to bgenv_init

 env/env_api_fat.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/env/env_api_fat.c b/env/env_api_fat.c
index 9f2a5cd..ae3f25f 100644
--- a/env/env_api_fat.c
+++ b/env/env_api_fat.c
@@ -125,11 +125,15 @@ bool write_env(CONFIG_PART *part, BG_ENVDATA *env)
        return result;
 }
 
-CONFIG_PART config_parts[ENV_NUM_CONFIG_PARTS];
+CONFIG_PART config_parts[ENV_NUM_CONFIG_PARTS] = {0};
 BG_ENVDATA envdata[ENV_NUM_CONFIG_PARTS];
 
 bool bgenv_init()
 {
+       for (int i = 0; i < ENV_NUM_CONFIG_PARTS; i++) {
+               free(config_parts[i].devpath);
+               free(config_parts[i].mountpoint);
+       }
        memset((void *)&config_parts, 0,
               sizeof(CONFIG_PART) * ENV_NUM_CONFIG_PARTS);
        /* enumerate all config partitions */
-- 
2.27.0

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/20200612175034.200573-1-tolga.hosgor%40siemens.com.

Reply via email to