[PATCH 5/6] ch: Unref @cfg in virCHProcessStop()

Michal Privoznik posted 6 patches 11 months ago
[PATCH 5/6] ch: Unref @cfg in virCHProcessStop()
Posted by Michal Privoznik 11 months ago
At the beginning of virCHProcessStop() the ref to driver config
is obtained (via virCHDriverGetConfig()), but corresponding unref
call is lacking. Use g_autoptr() to make sure the config is
unrefed always.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/ch/ch_process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c
index cbf98faaf0..79f5990cc1 100644
--- a/src/ch/ch_process.c
+++ b/src/ch/ch_process.c
@@ -997,11 +997,11 @@ virCHProcessStop(virCHDriver *driver,
                  virDomainObj *vm,
                  virDomainShutoffReason reason)
 {
+    g_autoptr(virCHDriverConfig) cfg = virCHDriverGetConfig(driver);
     int ret;
     int retries = 0;
     unsigned int hostdev_flags = VIR_HOSTDEV_SP_PCI;
     virCHDomainObjPrivate *priv = vm->privateData;
-    virCHDriverConfig *cfg = virCHDriverGetConfig(driver);
     virDomainDef *def = vm->def;
     size_t i;
 
-- 
2.48.1
Re: [PATCH 5/6] ch: Unref @cfg in virCHProcessStop()
Posted by Peter Krempa 11 months ago
On Thu, Mar 13, 2025 at 14:44:37 +0100, Michal Privoznik wrote:
> At the beginning of virCHProcessStop() the ref to driver config
> is obtained (via virCHDriverGetConfig()), but corresponding unref
> call is lacking. Use g_autoptr() to make sure the config is
> unrefed always.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/ch/ch_process.c | 2 +-

Reviewed-by: Peter Krempa <pkrempa@redhat.com>