[libvirt PATCH] ch: monitor: unref mon->vm before vm

Ján Tomko posted 1 patch 2 years, 8 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/403d6ae81dc58142734451edb6caf50a998a53df.1629382486.git.jtomko@redhat.com
src/ch/ch_monitor.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[libvirt PATCH] ch: monitor: unref mon->vm before vm
Posted by Ján Tomko 2 years, 8 months ago
Do not access 'mon' after unref'ing it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/ch/ch_monitor.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c
index 1648d05017..0f8752d1ed 100644
--- a/src/ch/ch_monitor.c
+++ b/src/ch/ch_monitor.c
@@ -543,9 +543,8 @@ void virCHMonitorClose(virCHMonitor *mon)
         g_free(mon->socketpath);
     }
 
+    virObjectUnref(mon->vm);
     virObjectUnref(mon);
-    if (mon->vm)
-        virObjectUnref(mon->vm);
 }
 
 static int
-- 
2.31.1

Re: [libvirt PATCH] ch: monitor: unref mon->vm before vm
Posted by Michal Prívozník 2 years, 8 months ago
On 8/19/21 4:15 PM, Ján Tomko wrote:
> Do not access 'mon' after unref'ing it.
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  src/ch/ch_monitor.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal