From nobody Sun Apr 28 19:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1622818884; cv=none; d=zohomail.com; s=zohoarc; b=hvWQEl6/GgU9icKoTBFDfM/mf8BcCQTwdhEQ0VgMz9uatrVgogtcn9uwcuavAgxBucCJNqHyc1csM8fRfmrxp+0UY4AxZPp9FTZ7dvMQjWacAGNoFJ1bj0dlx7V87VpC/ZvIy1E+yMAX6oB23K4pB6zq/mpM/FFvCZUqt77U4R8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622818884; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=jmrSVVDb2M9bSrVBbzCKBqoqezL6/MOR1TeHXoYpJBk=; b=jkVFENYVsZk1eZkP0TDpjGupkK1Ty3Y0oSv6dc5TSn5iAz5D0TGW/ZyVaqHdTzAG28HSNcSbLL0flbhU9LH3QjhI9dnGpl3txvxDNUOaKFnfwAsGqe3QJbtv6ruz2hiAE1je5rZ4dGO1NtGvPdSX3tiP/O1CMjio+Fop/Qb6j0g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 16228188848497.836096376360615; Fri, 4 Jun 2021 08:01:24 -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-377-hJTxjGr6POy70uSadrWoFw-1; Fri, 04 Jun 2021 11:01:20 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B6BD8015C6; Fri, 4 Jun 2021 15:01:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51F8C19C79; Fri, 4 Jun 2021 15:01:14 +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 73E341801265; Fri, 4 Jun 2021 15:01:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 154F1Bx9005079 for ; Fri, 4 Jun 2021 11:01:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id DDBA9189CE; Fri, 4 Jun 2021 15:01:11 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-114-239.ams2.redhat.com [10.36.114.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id E154B5B4A4; Fri, 4 Jun 2021 15:01:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622818883; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jmrSVVDb2M9bSrVBbzCKBqoqezL6/MOR1TeHXoYpJBk=; b=I7uwFpXytRlibI/b2zOZV87vw/WmqHhESW0E/K2t7FAK4COsO6DHOw2vcJbwEEvEXWo3CO lJIP8UpXD+opzuNpV+z1RQfRIPiZ22o+7r3vdhUNQAWFzAlgvqLrZgKKHHgDc2yHLuOUCa w36NgVR//ZFnz9XAQvIUU4X///8c/ls= X-MC-Unique: hJTxjGr6POy70uSadrWoFw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [PATCH] ch: set driver to NULL after freeing it Date: Fri, 4 Jun 2021 16:01:04 +0100 Message-Id: <20210604150104.155725-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.84 on 10.5.11.23 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) If the chStateInitialize method fails, we call chStateCleanup which free's all global state. It fails to set the global 'ch_driver' to NULL, however, so a later attempt to open the cloud hypervisor driver will succeed and then crash attempting to access freed memory. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/ch/ch_driver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 8c458a20bd..1ee33817f9 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -827,6 +827,7 @@ static int chStateCleanup(void) virObjectUnref(ch_driver->config); virMutexDestroy(&ch_driver->lock); g_free(ch_driver); + ch_driver =3D NULL; =20 return 0; } --=20 2.31.1