From nobody Mon Feb 9 16:12:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1586003141; cv=none; d=zohomail.com; s=zohoarc; b=iKxvSU3hnn0mtiD70jJvgno/0SjzHQRxK+PVJyZwHrU/NIfmyujLlgPSq9bTi0WvorgMBwG0L+lEjvNLhbp/Swd5UFdb+rcwTE0JCciDhks0XL1ze3ScAS9Yi3Gec3nk3CnEHFwZ8FacnzZOiA+D5iG4JPTgOlHHHkdoPK2SAfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586003141; h=Content-Type:Content-Transfer-Encoding:Cc: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=B7wjwW4kktbArsvMvX1086jM6kTZmn7Iq2jjE58VOA4=; b=nZ7Qmdhgma98gc9wXDat3xcMjOfY6NGQPaSbLMBqYmgTea07AbvlKNzWKT/zrb9Dx6dBRs8DKUJn1vMM3W/Xx/rjX2LTnpvMlcweYUmKT7cQ9CZVdd1HKO8Yp/dlrsVBHEjjXIpB4rBQHxyZ7AmJs1s8Eb84fK20j3nghfA7iKU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586003141304590.7165929835538; Sat, 4 Apr 2020 05:25:41 -0700 (PDT) Received: from localhost ([::1]:38404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jKhrn-0003P2-36 for importer@patchew.org; Sat, 04 Apr 2020 08:25:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54317) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jKhqZ-00024n-CO for qemu-devel@nongnu.org; Sat, 04 Apr 2020 08:24:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jKhqY-00032W-9f for qemu-devel@nongnu.org; Sat, 04 Apr 2020 08:24:23 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:52403 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jKhqY-00031s-44 for qemu-devel@nongnu.org; Sat, 04 Apr 2020 08:24:22 -0400 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-348-TkGJ7AS1NduzlbHmanlxCA-1; Sat, 04 Apr 2020 08:24:19 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2C4E61005513; Sat, 4 Apr 2020 12:24:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-152.ams2.redhat.com [10.36.112.152]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D942E96B7B; Sat, 4 Apr 2020 12:24:17 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 628A811358AF; Sat, 4 Apr 2020 14:24:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586003061; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B7wjwW4kktbArsvMvX1086jM6kTZmn7Iq2jjE58VOA4=; b=a5PsSbyYnw6JDCcBIv2HaIJYpd6g1QuAdS1YV25Lz8c3l3q6Qm/HYYTi6yIJkOQAFLl5HR uQImNtN3Dz7bRRwKZPMNX1FW/gDTOP+ecltuMK1Ik5wPoU8fxMPlpSV74mKi/PzNeCpKaz //HeBmny4kuS39tCA1ayaqOMb0+Wykc= X-MC-Unique: TkGJ7AS1NduzlbHmanlxCA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 3/3] qga/commands-posix: fix use after free of local_err Date: Sat, 4 Apr 2020 14:24:16 +0200 Message-Id: <20200404122416.1837-4-armbru@redhat.com> In-Reply-To: <20200404122416.1837-1-armbru@redhat.com> References: <20200404122416.1837-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladimir Sementsov-Ogievskiy , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy local_err is used several times in guest_suspend(). Setting non-NULL local_err will crash, so let's zero it after freeing. Also fix possible leak of local_err in final if(). Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20200324153630.11882-7-vsementsov@virtuozzo.com> Reviewed-by: Richard Henderson Signed-off-by: Markus Armbruster --- qga/commands-posix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 93474ff770..cc69b82704 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1773,6 +1773,7 @@ static void guest_suspend(SuspendMode mode, Error **e= rrp) } =20 error_free(local_err); + local_err =3D NULL; =20 if (pmutils_supports_mode(mode, &local_err)) { mode_supported =3D true; @@ -1784,6 +1785,7 @@ static void guest_suspend(SuspendMode mode, Error **e= rrp) } =20 error_free(local_err); + local_err =3D NULL; =20 if (linux_sys_state_supports_mode(mode, &local_err)) { mode_supported =3D true; @@ -1791,6 +1793,7 @@ static void guest_suspend(SuspendMode mode, Error **e= rrp) } =20 if (!mode_supported) { + error_free(local_err); error_setg(errp, "the requested suspend mode is not supported by the gue= st"); } else { --=20 2.21.1