From patchwork Fri Mar 15 01:47:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li RongQing X-Patchwork-Id: 10853973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 890A91708 for ; Fri, 15 Mar 2019 01:47:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 743E42A805 for ; Fri, 15 Mar 2019 01:47:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 681812A80B; Fri, 15 Mar 2019 01:47:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B033A2A805 for ; Fri, 15 Mar 2019 01:47:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbfCOBrZ (ORCPT ); Thu, 14 Mar 2019 21:47:25 -0400 Received: from mx56.baidu.com ([61.135.168.56]:50791 "EHLO tc-sys-mailedm01.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726571AbfCOBrZ (ORCPT ); Thu, 14 Mar 2019 21:47:25 -0400 Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm01.tc.baidu.com (Postfix) with ESMTP id 135DF2040056; Fri, 15 Mar 2019 09:47:12 +0800 (CST) From: Li RongQing To: x86@kernel.org, kvm@vger.kernel.org, vkuznets@redhat.com, brijesh.singh@amd.com Subject: [PATCH][v2] KVM: fix error handling in svm_cpu_init Date: Fri, 15 Mar 2019 09:47:12 +0800 Message-Id: <1552614432-4738-1-git-send-email-lirongqing@baidu.com> X-Mailer: git-send-email 1.7.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP sd->save_area should be freed in error path rename labels to make them readable suggested by Vitaly Fixes: 70cd94e60c733 ("KVM: SVM: VMRUN should use associated ASID when SEV is enabled") Signed-off-by: Li RongQing Reviewed-by: Brijesh Singh Cc: Vitaly Kuznetsov Reviewed-by: Vitaly Kuznetsov --- v1-->v2: rename labels to make them readable suggested by Vitaly arch/x86/kvm/svm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index f13a3a24d360..c6613d1dfa75 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -998,7 +998,7 @@ static int svm_cpu_init(int cpu) r = -ENOMEM; sd->save_area = alloc_page(GFP_KERNEL); if (!sd->save_area) - goto err_1; + goto err_free_sd; if (svm_sev_enabled()) { r = -ENOMEM; @@ -1006,17 +1006,18 @@ static int svm_cpu_init(int cpu) sizeof(void *), GFP_KERNEL); if (!sd->sev_vmcbs) - goto err_1; + goto err_free_saved_area; } per_cpu(svm_data, cpu) = sd; return 0; -err_1: +err_free_saved_area: + __free_page(sd->save_area); +err_free_sd: kfree(sd); return r; - } static bool valid_msr_intercept(u32 index)