From patchwork Tue Mar 12 07:28:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li RongQing X-Patchwork-Id: 10848677 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 012371390 for ; Tue, 12 Mar 2019 07:38:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF10B293DA for ; Tue, 12 Mar 2019 07:38:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDFF6293EE; Tue, 12 Mar 2019 07:38:01 +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 6E7CA293DA for ; Tue, 12 Mar 2019 07:38:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727089AbfCLHiA (ORCPT ); Tue, 12 Mar 2019 03:38:00 -0400 Received: from mx58.baidu.com ([61.135.168.58]:55882 "EHLO tc-sys-mailedm04.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726614AbfCLHiA (ORCPT ); Tue, 12 Mar 2019 03:38:00 -0400 Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm04.tc.baidu.com (Postfix) with ESMTP id 7BA42236C022; Tue, 12 Mar 2019 15:28:53 +0800 (CST) From: Li RongQing To: x86@kernel.org, kvm@vger.kernel.org Subject: [PATCH] KVM: fix error handling in svm_cpu_init Date: Tue, 12 Mar 2019 15:28:53 +0800 Message-Id: <1552375733-24985-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 Fixes: 70cd94e60c733 ("KVM: SVM: VMRUN should use associated ASID when SEV is enabled") Signed-off-by: Li RongQing Reviewed-by: Brijesh Singh --- arch/x86/kvm/svm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index f13a3a24d360..1787a484d21c 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1006,17 +1006,18 @@ static int svm_cpu_init(int cpu) sizeof(void *), GFP_KERNEL); if (!sd->sev_vmcbs) - goto err_1; + goto err_2; } per_cpu(svm_data, cpu) = sd; return 0; +err_2: + __free_page(sd->save_area); err_1: kfree(sd); return r; - } static bool valid_msr_intercept(u32 index)