Re: [PATCH 13/13] Turn virNetClient* into virObject instances | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
On Tue, Jul 17, 2012 at 02:36:18PM -0600, Eric Blake wrote:
> On 07/11/2012 07:35 AM, Daniel P. Berrange wrote:
> > From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> >
> > Make all the virNetClient* objects use virObject APIs for
> > reference counting
> >
> > Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> > ---
>
> > @@ -286,19 +294,22 @@ static virNetClientPtr virNetClientNew(virNetSocketPtr sock,
>
> >
> > - if (virMutexInit(&client->lock) < 0)
> > + if (virMutexInit(&client->lock) < 0) {
> > + VIR_FREE(client);
> > goto error;
>
> Hmm - this discards the fact that client has a ref-count of 1, and thus
> fails to poison that memory (one of the benefits of always going through
> unref is that that poisoning helps detect use-after-free bugs).
> Thankfully, though, there is no other allocated memory owned by 'client'
> at this point in time, so skipping the dispose method is not technically
> a leak; furthermore, since the dispose method tries to call
> virMutexDestroy but we know the mutex failed to initialize, I think it's
> the best we can do. You made me think about this, but in the end I
> agree it is right, even though it looks fishy.
FYI, this will be temporary nastiness. I intend to actually add a
virMutex to the virObjectPtr base object in a future patch series,
so subclasses won't need to maintain their own mutexes. So we'll
easily be able todo the right thing wrt to poisoning then.
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list
[Virt Tools] [Libvirt Users] [Fedora Users] [Fedora Legacy] [Fedora Maintainers] [Fedora Desktop] [Fedora SELinux] [Big List of Linux Books] [Yosemite News] [Yosemite Photos] [KDE Users] [Fedora Tools]