[PATCH v2 01/27] hypervFreeInvokeParams: Don't use VIR_DISPOSE_N for freeing 'params'

Peter Krempa posted 27 patches 5 years ago
[PATCH v2 01/27] hypervFreeInvokeParams: Don't use VIR_DISPOSE_N for freeing 'params'
Posted by Peter Krempa 5 years ago
The struct doesn't contain any secrets to clear before freeing and even
if it did VIR_DISPOSE_N wouldn't help as the struct contains only
pointers thus the actual memory pointing to isn't sanitized.

Just free the params array pointer and then the struct itself.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/hyperv/hyperv_wmi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index c14ff0e64a..8bb6f591f1 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -184,8 +184,8 @@ hypervFreeInvokeParams(hypervInvokeParamsListPtr params)
         }
     }

-    VIR_DISPOSE_N(params->params, params->nbAvailParams);
-    VIR_FREE(params);
+    g_free(params->params);
+    g_free(params);
 }


-- 
2.29.2

Re: [PATCH v2 01/27] hypervFreeInvokeParams: Don't use VIR_DISPOSE_N for freeing 'params'
Posted by Daniel P. Berrangé 5 years ago
On Tue, Feb 02, 2021 at 05:55:38PM +0100, Peter Krempa wrote:
> The struct doesn't contain any secrets to clear before freeing and even
> if it did VIR_DISPOSE_N wouldn't help as the struct contains only
> pointers thus the actual memory pointing to isn't sanitized.
> 
> Just free the params array pointer and then the struct itself.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/hyperv/hyperv_wmi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|