Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp665791ybv; Thu, 13 Feb 2020 07:26:07 -0800 (PST) X-Google-Smtp-Source: APXvYqwzrJgCgiSMoQKhVpwBCbNiZXNZDyI7NQ+dAIqlMKIoFb1Q24Jv70T5zq483gorx50TEyJ3 X-Received: by 2002:a54:450d:: with SMTP id l13mr3317599oil.117.1581607566879; Thu, 13 Feb 2020 07:26:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581607566; cv=none; d=google.com; s=arc-20160816; b=oYcEca2VIuxGDf0JdgXGy83x4yO2xvGGlPZ5P8AQbvdq3B6RVLAhTV6wSIm9WCQa9c YaBIPJHGb/g49fX7uAAO7dsSsFcA1uQunSOB1MbFaXzaZxE1z8kmZwdHTwPqxUmnhiCB TDnYU3mCZNtOrPY4xt/T0n2JRdowxxYr+ao2B9Wkx+njryjl7HGWG3mUXoElq4YRP4RO QxhtuDU8kva7DGbIzNtpByNK8UKSG3TcNmLMlJR1Rs1Dggw7NZ+GTEj0pT2TSqQhvqTQ sMlcon8LrMpgXQFi8iLbpFqVzpS+svBOe9wqtA4PE3Bnwe67eEgTvZseFRaVH+5YNW/V aZPA== 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=fnCN2hg3nwxKZ61APRQktTkSBPrvDWTIxJdi3ddN/tI=; b=vrfspJFEMxx0jqC+YmCpPv9gv6b0246vkn8DLL1THXGL9MhMCbjyKkToyt9IdyhQLj AMv+52CyWGN2Pid5CRxHLAr2Nr+f+8gkG6Fz0bkN3fg21oU8Vlq1ZgEYvgLHDo1iNMFL HkY4xQzLPPzMyqKGfexhjI+DyUwwL9hHU6DZGov4zWV/v5fehviyF4kChc+3tPBhDa4b Amt1cHBTelfVPK7x4cdjIannAuaae5oUMV1inwfbUuR0NA/6UxiooqQ1aX1JsXi+RQem S+edUbTKECEGEf8R/hxsWuDMk+LlrPuoHyk5z7I81cvMZ0ofWeicpIxGy1j0Tpz1/97l cZNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1xJgtdIf; 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 a92si1233951otc.294.2020.02.13.07.25.54; Thu, 13 Feb 2020 07:26:06 -0800 (PST) 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=1xJgtdIf; 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 S2387422AbgBMPZP (ORCPT + 99 others); Thu, 13 Feb 2020 10:25:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:35604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727873AbgBMPXp (ORCPT ); Thu, 13 Feb 2020 10:23:45 -0500 Received: from localhost (unknown [104.132.1.104]) (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 800B3246B5; Thu, 13 Feb 2020 15:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607424; bh=c6YHXyVYeo56alttnMPtiq+Xf9OGWRPcr2cFn1Y7gX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1xJgtdIfnf5MqkqPH7thUN5qAef2NBcuE68HY2wq+CXBchFBOXnuKgNkD6IHu23QU yEacl/CrX4StDpzhS+11XlAgNHTJjOzKCoTXIyehnBDV4mCfeG15wIeKMCxeHwEOv5 g4MCzKveIh6oBtGURYkD5/8fiGL9OyIHCSJM/fkY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Greg Kurz , Sean Christopherson , Paul Mackerras , Paolo Bonzini Subject: [PATCH 4.9 054/116] KVM: PPC: Book3S HV: Uninit vCPU if vcore creation fails Date: Thu, 13 Feb 2020 07:19:58 -0800 Message-Id: <20200213151903.928016018@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151842.259660170@linuxfoundation.org> References: <20200213151842.259660170@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: Sean Christopherson commit 1a978d9d3e72ddfa40ac60d26301b154247ee0bc upstream. Call kvm_vcpu_uninit() if vcore creation fails to avoid leaking any resources allocated by kvm_vcpu_init(), i.e. the vcpu->run page. Fixes: 371fefd6f2dc4 ("KVM: PPC: Allow book3s_hv guests to use SMT processor modes") Cc: stable@vger.kernel.org Reviewed-by: Greg Kurz Signed-off-by: Sean Christopherson Acked-by: Paul Mackerras Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kvm/book3s_hv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1766,7 +1766,7 @@ static struct kvm_vcpu *kvmppc_core_vcpu mutex_unlock(&kvm->lock); if (!vcore) - goto free_vcpu; + goto uninit_vcpu; spin_lock(&vcore->lock); ++vcore->num_threads; @@ -1782,6 +1782,8 @@ static struct kvm_vcpu *kvmppc_core_vcpu return vcpu; +uninit_vcpu: + kvm_vcpu_uninit(vcpu); free_vcpu: kmem_cache_free(kvm_vcpu_cache, vcpu); out: