[libvirt] [PATCH v2 1/5] uml: Fix umlProcessAutoDestroyDom dom processing

John Ferlan posted 5 patches 7 years, 1 month ago
[libvirt] [PATCH v2 1/5] uml: Fix umlProcessAutoDestroyDom dom processing
Posted by John Ferlan 7 years, 1 month ago
There's no need to check if @dom exists before trying to
call virDomainObjListRemove since it must exist due to
prior checks.

Additionally, if we do remove the @dom, then set it to NULL
so that the virObjectUnlock isn't referencing something that
is deleted.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/uml/uml_driver.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index ab7fa7f273..ff2e7ac66b 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -747,8 +747,10 @@ static int umlProcessAutoDestroyDom(void *payload,
                                      VIR_DOMAIN_EVENT_STOPPED,
                                      VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
 
-    if (dom && !dom->persistent)
+    if (!dom->persistent) {
         virDomainObjListRemove(data->driver->domains, dom);
+        dom = NULL;
+    }
 
     if (dom)
         virObjectUnlock(dom);
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/5] uml: Fix umlProcessAutoDestroyDom dom processing
Posted by Daniel P. Berrangé 7 years ago
On Mon, Apr 02, 2018 at 09:06:12AM -0400, John Ferlan wrote:
> There's no need to check if @dom exists before trying to
> call virDomainObjListRemove since it must exist due to
> prior checks.
> 
> Additionally, if we do remove the @dom, then set it to NULL
> so that the virObjectUnlock isn't referencing something that
> is deleted.
> 
> Signed-off-by: John Ferlan <jferlan@redhat.com>
> ---
>  src/uml/uml_driver.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/5] uml: Fix umlProcessAutoDestroyDom dom processing
Posted by Marc Hartmayer 7 years, 1 month ago
On Mon, Apr 02, 2018 at 03:06 PM +0200, John Ferlan <jferlan@redhat.com> wrote:
> There's no need to check if @dom exists before trying to
> call virDomainObjListRemove since it must exist due to
> prior checks.
>
> Additionally, if we do remove the @dom, then set it to NULL
> so that the virObjectUnlock isn't referencing something that
> is deleted.
>
> Signed-off-by: John Ferlan <jferlan@redhat.com>
> ---
>  src/uml/uml_driver.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
> index ab7fa7f273..ff2e7ac66b 100644
> --- a/src/uml/uml_driver.c
> +++ b/src/uml/uml_driver.c
> @@ -747,8 +747,10 @@ static int umlProcessAutoDestroyDom(void *payload,
>                                       VIR_DOMAIN_EVENT_STOPPED,
>                                       VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
>
> -    if (dom && !dom->persistent)
> +    if (!dom->persistent) {
>          virDomainObjListRemove(data->driver->domains, dom);
> +        dom = NULL;
> +    }
>
>      if (dom)
>          virObjectUnlock(dom);
> --
> 2.13.6
>
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>

Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>

--
Beste Grüße / Kind regards
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


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