[libvirt] [PATCH v5 1/3] lockd: Need to Unref @srv when done with it.

Martin Kletzander mkletzan at redhat.com
Mon Oct 30 13:41:45 UTC 2017


On Mon, Oct 30, 2017 at 07:14:37AM -0400, John Ferlan wrote:
>Commit id '252610f7d' used a hash table to store the @srv, but
>didn't handle the virObjectUnref if virNetDaemonNew failed nor
>did it use virObjectUnref once successfully placed into the table
>which will now be managing it's lifetime (and would cause the
>virObjectRef if successfully inserted into the table).
>
>Signed-off-by: John Ferlan <jferlan at redhat.com>
>---
> src/locking/lock_daemon.c | 3 +++
> 1 file changed, 3 insertions(+)
>
>diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
>index fe3eaf9032..1b7fd86b3a 100644
>--- a/src/locking/lock_daemon.c
>+++ b/src/locking/lock_daemon.c
>@@ -173,6 +173,8 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool privileged)
>     if (!(lockd->dmn = virNetDaemonNew()) ||
>         virNetDaemonAddServer(lockd->dmn, srv) < 0)
>         goto error;
>+    virObjectUnref(srv);
>+    srv = NULL;
>

Having 'cleanup' label would look bit more like other functions, but this works
as well, so ACK.  Since this may impact lot of users and should get some
testing, I'd rather wait after release.

>     if (!(lockd->lockspaces = virHashCreate(VIR_LOCK_DAEMON_NUM_LOCKSPACES,
>                                             virLockDaemonLockSpaceDataFree)))
>@@ -184,6 +186,7 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool privileged)
>     return lockd;
>
>  error:
>+    virObjectUnref(srv);
>     virLockDaemonFree(lockd);
>     return NULL;
> }
>-- 
>2.13.6
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20171030/63739b1e/attachment-0001.sig>


More information about the libvir-list mailing list