Re: [PATCH 7/8] secret: Properly handle @def after virSecretObjAdd in driver

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

 




On 07/11/2017 11:52 AM, Michal Privoznik wrote:
> On 06/03/2017 03:27 PM, John Ferlan wrote:
>> Since the virSecretObjListAdd technically consumes @def on success,
>> the secretDefineXML should fetch the @def from the object afterwards
>> and manage as an @objdef and set @def = NULL immediately.
> 
> Really? virSecretObjListAdd sets ->def pointer in the object, but it
> doesn't touch the definition otherwise. So I think a caller is safe to
> continue using the pointer.
> 
> Michal
> 

Let's consider the code before my change...

@def is added to the @obj

"Something" causes us to jump to the "restore_backup:" label and @backup
== NULL.

That means virSecretObjListRemove runs and because @obj has @def it ends
up calling virSecretDefFree

The very next thing we do is call virSecretDefFree on the same @def address.

While it is the same thing and I could do a VIR_STEAL_PTR(objdef, def);
instead, the patch just follows the pattern I've adopted in other
patches where @def = NULL and objdef = vir*ObjGetDef()

IDC either way, but to avoid a path where @def could be free'd twice,
something needs to be done.

John

--
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