From f4006107c07a7610aa9b32b538726de6d0e109b5 Mon Sep 17 00:00:00 2001 From: Wenchao Hao Date: Thu, 3 Dec 2020 11:12:37 +0800 Subject: fwparam_ppc: Fix memory leak in fwparam_ppc.c calloc() is called because loop_devs() to allocate memory which stored in array ofwdev. These memory should be freed at the end. Signed-off-by: Wenchao Hao Signed-off-by: Zhiqiang Liu Signed-off-by: Wu Bo --- utils/fwparam_ibft/fwparam_ppc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/fwparam_ibft/fwparam_ppc.c b/utils/fwparam_ibft/fwparam_ppc.c index 6a45b8c..da9d76e 100644 --- a/utils/fwparam_ibft/fwparam_ppc.c +++ b/utils/fwparam_ibft/fwparam_ppc.c @@ -446,6 +446,7 @@ int fwparam_ppc_boot_info(struct boot_context *context) char filename[FILENAMESZ]; int error; char *devtree; + int i; /* * For powerpc, our operations are fundamentally to locate @@ -511,6 +512,10 @@ free_bootpath_val: free_devtree: free(devtree); + for (i = 0; i < dev_count; i++) + if (ofwdevs[i]) + free(ofwdevs[i]); + return error; } @@ -525,6 +530,7 @@ int fwparam_ppc_get_targets(struct list_head *list) struct boot_context *context; int error; char *devtree; + int i; /* * For powerpc, our operations are fundamentally to locate @@ -592,5 +598,9 @@ free_bootpath_val: free_devtree: free(devtree); + for (i = 0; i < dev_count; i++) + if (ofwdevs[i]) + free(ofwdevs[i]); + return error; } -- cgit v1.2.1