[libvirt] [PATCH v2 2/3] virDomainDeviceInfoParseXML: Clear whole @info on failure

Michal Privoznik posted 3 patches 7 years, 7 months ago
[libvirt] [PATCH v2 2/3] virDomainDeviceInfoParseXML: Clear whole @info on failure
Posted by Michal Privoznik 7 years, 7 months ago
Currently, if parsing of device info fails info->alias is freed.
It doesn't make much sense to leave the rest of the struct
behind.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/conf/domain_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0bc2e2f94..67095114c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6469,7 +6469,7 @@ virDomainDeviceInfoParseXML(xmlNodePtr node,
     ret = 0;
  cleanup:
     if (ret < 0)
-        VIR_FREE(info->alias);
+        virDomainDeviceInfoClear(info);
     VIR_FREE(type);
     VIR_FREE(rombar);
     return ret;
-- 
2.13.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/3] virDomainDeviceInfoParseXML: Clear whole @info on failure
Posted by Martin Kletzander 7 years, 7 months ago
On Tue, Oct 03, 2017 at 12:58:58PM +0200, Michal Privoznik wrote:
>Currently, if parsing of device info fails info->alias is freed.
>It doesn't make much sense to leave the rest of the struct
>behind.
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> src/conf/domain_conf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>

ACK, trivial

>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index 0bc2e2f94..67095114c 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -6469,7 +6469,7 @@ virDomainDeviceInfoParseXML(xmlNodePtr node,
>     ret = 0;
>  cleanup:
>     if (ret < 0)
>-        VIR_FREE(info->alias);
>+        virDomainDeviceInfoClear(info);
>     VIR_FREE(type);
>     VIR_FREE(rombar);
>     return ret;
>-- 
>2.13.5
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list