[PATCH 0/2] Another round of CH driver fixes

*** BLURB HERE *** Michal Prívozník (2): ch_driver: Avoid driver double free virCHDriverConfig: Drop @uri member src/ch/ch_conf.c | 1 - src/ch/ch_conf.h | 1 - src/ch/ch_driver.c | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) -- 2.31.1

In one of my recent patches I made chStateInitialize() return VIR_DRV_STATE_INIT_SKIPPED if CH_CMD doesn't exist. What I did not realize back then was that chStateCleanup() would be called twice. This is not a problem per-se because the function is a NOP if driver is NULL. but the problem is that at the end it calls plain g_free(driver) which does not set driver to NULL. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/ch/ch_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 7baacd7400..374f6e5542 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -826,7 +826,7 @@ static int chStateCleanup(void) virObjectUnref(ch_driver->caps); virObjectUnref(ch_driver->config); virMutexDestroy(&ch_driver->lock); - g_free(ch_driver); + g_clear_pointer(&ch_driver, g_free); return 0; } -- 2.31.1

This member is unused (apart from only being set in virCHDriverConfigNew()), and never freed really (leading to a memleak). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/ch/ch_conf.c | 1 - src/ch/ch_conf.h | 1 - 2 files changed, 2 deletions(-) diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index 5f156dfe44..ed0fffe5d6 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -141,7 +141,6 @@ virCHDriverConfigNew(bool privileged) if (!(cfg = virObjectNew(virCHDriverConfigClass))) return NULL; - cfg->uri = g_strdup(privileged ? "ch:///system" : "ch:///session"); if (privileged) { if (virGetUserID(CH_USER, &cfg->user) < 0) return NULL; diff --git a/src/ch/ch_conf.h b/src/ch/ch_conf.h index d856825377..37c36d9a09 100644 --- a/src/ch/ch_conf.h +++ b/src/ch/ch_conf.h @@ -35,7 +35,6 @@ struct _virCHDriverConfig { char *stateDir; char *logDir; - char *uri; uid_t user; gid_t group; -- 2.31.1

On 6/7/21 3:47 PM, Michal Privoznik wrote:
*** BLURB HERE ***
Michal Prívozník (2): ch_driver: Avoid driver double free virCHDriverConfig: Drop @uri member
src/ch/ch_conf.c | 1 - src/ch/ch_conf.h | 1 - src/ch/ch_driver.c | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-)
Series: Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Jano Tomko
-
Michal Privoznik