Re: [PATCH v2 1/6] test_driver: implement virDomainAttachDeviceFlags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 16, 2019 at 5:39 PM Erik Skultety <eskultet@xxxxxxxxxx> wrote:
>
> ...
>
> > +
> > +    if (operation == TEST_DEVICE_DETACH)
> > +        parse_flags |= VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
>
> ^This should be added by patch 3/5
>
> > +
> > +    if (xml) {
> > +        if (!(dev = virDomainDeviceDefParse(xml, def,
> > +                                            driver->caps, driver->xmlopt,
> > +                                            NULL, parse_flags)))
> > +            goto cleanup;
> > +    } else if (alias) {
> > +        if (VIR_ALLOC(dev) < 0 || virDomainDefFindDevice(def, alias, dev, true) < 0)
> > +            goto cleanup;
> > +    }
> > +
> > +    switch (operation) {
> > +    case TEST_DEVICE_ATTACH:
> > +        if (testDomainAttachDeviceLiveAndConfig(def, dev) < 0)
> > +            goto cleanup;
> > +        break;
> > +    case TEST_DEVICE_DETACH:
> > +        break;
> > +    case TEST_DEVICE_UPDATE:
> > +        break;
> > +    }
> > +
> > +    ret = 0;
> > + cleanup:
> > +    if (xml)
> > +        virDomainDeviceDefFree(dev);
> > +    else
> > +        VIR_FREE(dev);
>
> virDomainDeviceDefFree() can handle both cases.

It cannot! This got me as well and made me wonder!

Try attaching a device with an alias and then try detaching it with
virDomainDetachDeviceAlias and use virDomainDeviceDefFree to free the
resource.

The program crashes with:
free(): double free detected in tcache 2

Ilias

>
> Reviewed-by: Erik Skultety <eskultet@xxxxxxxxxx>

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux