Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3805428ybi; Mon, 29 Jul 2019 13:00:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEa3/VK7f5AApMSI8VFrxFl6hocX2bAWO3WBm2OiXu62Ichj8SYijE5XxQs0PXszG0222f X-Received: by 2002:a17:902:2808:: with SMTP id e8mr107463081plb.317.1564430404143; Mon, 29 Jul 2019 13:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430404; cv=none; d=google.com; s=arc-20160816; b=S66L8MZj9BnJt3gk5f5Jxdm7WjkzygZh5+6wbKnsNj8YgNnYu+G1IJFLGT+FpcVsL1 oNujrGIRGKaHq1mofSaiCVkuV/6IFkOTJe86Jc6b/tbJ9vw7hsao4y1Tx7y55Nf2KOyX 92FxDbzsacf+wU7ZK3CPV8AyMVxhHNC4HAW9i6a7qpC4RscjpF8DItDyQM/BYTr/Smc+ YLNSBGM8NXx86fJb03RTSnJZ0vWQnVahPDUKYcbjZFojyCATMKN5YmdFuaCL1HJ+/ABv 8T+f/hAiqpyDyF7+Rh/TZ/QIZoDAeIfQimWLHKG97EpgAXYPSyQ+Pod/ztJYtGuApeMA p35g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VMozp89qzz7EC+BqMn1vUlom3wPWNyDzkSJeG0dDIg0=; b=WcqFchEg4+RQJMq3FWQSSLNPv7f37vL5arGqEv1sjgRxmyOe5u7LuPquuCTTE/y/6E uhxKGPW0Yid0Y3JY7NC7VOnb0h+HG+YTx/eZICeJLSAAfVGO5LATDM/KS0YTMGYulv9u UbctV1skyQYLe75CZAbgjyAUQpxrT9jo8ErQzZ/FXJeWD49Rl1+bVfrmW15nMffOMlkl mSr96iF8rQ9U2DmXDhv71Z8shLy5BLKjiOlCwEIjprt22INycepgnj6iVh2rSN9x8fyw 5Yfjr9TIpthWwNnrCh+GcitOM6OiSABVvJBfbfEKLzrTGM/CyyIcP22JbgXfxwuiOZyz EUdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BA4oiwcd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si25451236pjr.18.2019.07.29.12.59.49; Mon, 29 Jul 2019 13:00:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BA4oiwcd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391118AbfG2T6L (ORCPT + 99 others); Mon, 29 Jul 2019 15:58:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:46588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729724AbfG2TyC (ORCPT ); Mon, 29 Jul 2019 15:54:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E8C20204EC; Mon, 29 Jul 2019 19:54:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564430041; bh=NUbrjwjYeXygtv84i9f7XHC8o03n9nhYjKpLang2j+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BA4oiwcdUoZh4ri8MHzszB4qJrUpsqnQZnFRz8qHyfM5kE5YDXR0bwtV/MRLB5d4F 8OzBq+C5NLLIET3+TgppgIFDSIRT7WYsxIpRvrouZO2pjRXvSKMRLgPV1bwMNQhdgS Caaax9YguKUKt32dtGeVE+hzF9lrBw8egOjaEVhY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Michael Ellerman Subject: [PATCH 5.2 177/215] KVM: PPC: Book3S HV: XIVE: fix rollback when kvmppc_xive_create fails Date: Mon, 29 Jul 2019 21:22:53 +0200 Message-Id: <20190729190810.703221068@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cédric Le Goater commit 9798f4ea71eaf8eaad7e688c5b298528089c7bf8 upstream. The XIVE device structure is now allocated in kvmppc_xive_get_device() and kfree'd in kvmppc_core_destroy_vm(). In case of an OPAL error when allocating the XIVE VPs, the kfree() call in kvmppc_xive_*create() will result in a double free and corrupt the host memory. Fixes: 5422e95103cf ("KVM: PPC: Book3S HV: XIVE: Replace the 'destroy' method by a 'release' method") Cc: stable@vger.kernel.org # v5.2+ Signed-off-by: Cédric Le Goater Tested-by: Michael Ellerman Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/6ea6998b-a890-2511-01d1-747d7621eb19@kaod.org Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kvm/book3s_xive.c | 4 +--- arch/powerpc/kvm/book3s_xive_native.c | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) --- a/arch/powerpc/kvm/book3s_xive.c +++ b/arch/powerpc/kvm/book3s_xive.c @@ -1986,10 +1986,8 @@ static int kvmppc_xive_create(struct kvm xive->single_escalation = xive_native_has_single_escalation(); - if (ret) { - kfree(xive); + if (ret) return ret; - } return 0; } --- a/arch/powerpc/kvm/book3s_xive_native.c +++ b/arch/powerpc/kvm/book3s_xive_native.c @@ -1090,9 +1090,9 @@ static int kvmppc_xive_native_create(str xive->ops = &kvmppc_xive_native_ops; if (ret) - kfree(xive); + return ret; - return ret; + return 0; } /*