[libvirt] [PATCH] qemu: fix use a nonexist address in qemuDomainAttachDeviceConfig

Peter Krempa pkrempa at redhat.com
Tue Dec 16 12:00:48 UTC 2014


On 12/15/14 10:10, Luyao Huang wrote:
> We free them before, then use it. This make we always do

We clear the pointer, not free.

> virDomainDefAddImplicitControllers when attach a disk.
> 
> Signed-off-by: Luyao Huang <lhuang at redhat.com>
> ---
>  src/qemu/qemu_driver.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index df3ba6d..a9afa5d 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -7223,10 +7223,10 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
>          if (virDomainDiskInsert(vmdef, disk))
>              return -1;
>          /* vmdef has the pointer. Generic codes for vmdef will do all jobs */
> -        dev->data.disk = NULL;

The comment even explains why the line is there. From that point on, the
pointer is owned by 'vmdef' and thus the original needs to be cleared so
that it isn't freed (and doulbe freed) later on.


>          if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO)

Additionally, 'disk' contains still a valid copy of the pointer so the
code should run just fine.

>              if (virDomainDefAddImplicitControllers(vmdef) < 0)
>                  return -1;
> +        dev->data.disk = NULL;

So moving the line here doesn't make sense.

>          if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) < 0)
>              return -1;
>          break;
> 

NACK,

Peter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141216/c4244caf/attachment-0001.sig>


More information about the libvir-list mailing list