From nobody Mon Feb 9 00:38:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623073685; cv=none; d=zohomail.com; s=zohoarc; b=nKq+qaQ04U+JbzY4xSoUOCOA4X9f3GJ09ETKdW1QK+0SExq/W8FTxZ7vDV6wGzP0WSDBo89Y11p3CMYAcbzqb1Ym7/dEqu4AgpzDhPVHIYb4I2ldO1fOtJttKp/J6BYmV1Dt67hDT6p7LhGCLLIJ85dS5h93ucY7mPVsJBc5FUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623073685; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VcYsXY5lic7GQQ4bqfgm2KIeBSXSALxMJodB2IvMwTQ=; b=ee5+n3wBSaEpZ8ibboDu6lqllyozIYOab1L3v6WZv10BBbgS9cfjSbFyABayk5vZQ0LO3+mngpK5a0Ni63vr01jUe39WxhusjCh9xFQ4kKOP0guGRQnuO5oHGq6bzwp6Y2a+ZAv9HkwYSJBonpT3tUJ1IHN8fB6NoTaeJxbTOmA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1623073685569664.1102997088112; Mon, 7 Jun 2021 06:48:05 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-pFX8STvANDC0rgQXQuazMQ-1; Mon, 07 Jun 2021 09:48:03 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5649F108C30B; Mon, 7 Jun 2021 13:47:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 15F0E5D9FC; Mon, 7 Jun 2021 13:47:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 482614EA6C; Mon, 7 Jun 2021 13:47:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 157Dlt0I002299 for ; Mon, 7 Jun 2021 09:47:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 700AF5D9DC; Mon, 7 Jun 2021 13:47:55 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id E82795D9C0 for ; Mon, 7 Jun 2021 13:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623073684; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VcYsXY5lic7GQQ4bqfgm2KIeBSXSALxMJodB2IvMwTQ=; b=S7AbqU6ZbPZ0p6BNRBvdgh3JDMlkFRgiNqtm1eYtT6kBQOztjDZB7C9K6wpEiB4d3Si7Wa 2vyvHnDPrVprofsAR+Su99x40nKPT4GGs1u1tNKsgAHkGErYSIdaKSDHSLDganH37oi7Bh NgR4fXtS14XP6SdWUypKp7RQCblXBsQ= X-MC-Unique: pFX8STvANDC0rgQXQuazMQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] ch_driver: Avoid driver double free Date: Mon, 7 Jun 2021 15:47:47 +0200 Message-Id: <04bf2b5f40a1e8c56ac324a860ed40f55589f8ed.1623073607.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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 --- 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); =20 return 0; } --=20 2.31.1