[libvirt] [PATCH] conf: use virDomainDeviceDefFree free dev
Peter Krempa
pkrempa at redhat.com
Thu Sep 19 15:23:26 UTC 2019
On Thu, Sep 19, 2019 at 10:33:53 -0300, Daniel Henrique Barboza wrote:
>
>
> On 9/19/19 5:01 AM, Xu Yandong wrote:
> > In function virDomainDeviceDefParse, we shoud use virDomainDeviceDefFree
> > free data structure avoid potential memory leak.
> >
> > Signed-off-by: Xu Yandong <xuyandong2 at huawei.com>
> > ---
> > src/conf/domain_conf.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> > index 848c831330..8fb9480827 100644
> > --- a/src/conf/domain_conf.c
> > +++ b/src/conf/domain_conf.c
> > @@ -16504,7 +16504,8 @@ virDomainDeviceDefParse(const char *xmlStr,
> > return dev;
> > error:
> > - VIR_FREE(dev);
> > + virDomainDeviceDefFree(dev);
> > + dev = NULL;
> > goto cleanup;
>
>
> Just noticed that the current master code does not have this potential
> leak anymore. It was fixed by commit 475777c9ec, introducing
> VIR_AUTOFREE() for virDomainDeviceDefPtr.
VIR_AUTOFREE calls only a VIR_FREE to release the memory associated with
'dev', so if this patch fixes a leak of one of the members of the 'dev'
a patch is still required with a different approach. E.g. VIR_AUTOPTR.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190919/9b78ff32/attachment-0001.sig>
More information about the libvir-list
mailing list