Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp381775ybv; Wed, 19 Feb 2020 23:50:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzXxiROmgDpg7erd6Sb3yNq1RLx6zbQoANTBiHmUSUZenJmhnAPiA+/9j8do69/H2uZF5gD X-Received: by 2002:aca:5f87:: with SMTP id t129mr1149222oib.36.1582185005270; Wed, 19 Feb 2020 23:50:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582185005; cv=none; d=google.com; s=arc-20160816; b=WSmH4ZQOrpNvKcTd/IzJahuFVa7hIvmbAGKgz45SuGbaCIaND1pEXdBnLlQL6XEdxa zy5zkdQrSSvyaRZYAQ1MvE+xmlZ17XojzwenOX4gJeftQNWAn1onH2vZIong45scwWCc yPtsNPDY8ckXdfuiu1RExm53VgfUt9t3KztB9i2L/1LbHimivgkEKp0y1SmnYxAFEQKQ gvR4z0RlcfqpOY5IbZLTP6e+PQu0X1i8dmZWRC/lhckwbXwQew1Cu0KuR29QDwsaWjgz P5OZuF4XRDI2xVLCtRoQWEtub4FPKjukoyhkCAKdQQI4cq1hNHCm7IeY0Grpih8ZLwii Ym+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:to:from; bh=ZsM7m6uyhEcGKTrtt+9aTtRRSUrTt37VCaMfPpxkfy4=; b=LtQiuHhdlJtyjZNZs+3lcZBGRQI2ODwN9I4vtpUuQDO+jRBtIt/7wmjMKaaeKdHP6s nki/BTzuQ0/gB93kQeyBlnFbAIvrh1CsViTb4v1N04Z6CjSXof5/WZ6PNxXB1RFNS1Ef CzIyfEWk03ntQGCMbFDFPFL5j8iqktdMgidqmWgm/v4VP3uwuipOQv7QdoCjgtAcsX4v Wx98qLma61M78+1hDpLMc2Nj7gDM43Lp+YC4Q8j8S+tWX+whxc2ceTOhiFJfMPziDBSH GHiCugVSBF0PcxgspAvS6yF1YVr6oxmInj2QfSjKlei8a4sdpG3tidCRYhLeK3NvvjGs DrKQ== ARC-Authentication-Results: i=1; mx.google.com; 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 65si11783127oif.14.2020.02.19.23.49.53; Wed, 19 Feb 2020 23:50:05 -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; 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 S1726989AbgBTHsq (ORCPT + 99 others); Thu, 20 Feb 2020 02:48:46 -0500 Received: from mx60.baidu.com ([61.135.168.60]:28371 "EHLO tc-sys-mailedm05.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726501AbgBTHsq (ORCPT ); Thu, 20 Feb 2020 02:48:46 -0500 X-Greylist: delayed 540 seconds by postgrey-1.27 at vger.kernel.org; Thu, 20 Feb 2020 02:48:44 EST Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm05.tc.baidu.com (Postfix) with ESMTP id E37C61EBA001; Thu, 20 Feb 2020 15:39:32 +0800 (CST) From: Li RongQing To: pbonzini@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][resend] KVM: fix error handling in svm_cpu_init Date: Thu, 20 Feb 2020 15:39:32 +0800 Message-Id: <1582184372-15876-1-git-send-email-lirongqing@baidu.com> X-Mailer: git-send-email 1.7.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sd->save_area should be freed in error path Fixes: 70cd94e60c733 ("KVM: SVM: VMRUN should use associated ASID when SEV is enabled") Signed-off-by: Li RongQing Reviewed-by: Brijesh Singh Reviewed-by: Vitaly Kuznetsov --- arch/x86/kvm/svm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index a3e32d61d60c..b8e948c65f51 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1014,7 +1014,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; @@ -1022,14 +1022,16 @@ 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; -- 2.16.2