From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B599CA9EAF for ; Thu, 24 Oct 2019 10:27:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D256520684 for ; Thu, 24 Oct 2019 10:27:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409079AbfJXK1u (ORCPT ); Thu, 24 Oct 2019 06:27:50 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:45634 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390754AbfJXK1t (ORCPT ); Thu, 24 Oct 2019 06:27:49 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R451e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07417;MF=shannon.zhao@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Tg32PEs_1571912865; Received: from localhost(mailfrom:shannon.zhao@linux.alibaba.com fp:SMTPD_---0Tg32PEs_1571912865) by smtp.aliyun-inc.com(127.0.0.1); Thu, 24 Oct 2019 18:27:46 +0800 From: Shannon Zhao To: kvmarm@lists.cs.columbia.edu, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, christoffer.dall@arm.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC 2/7] KVM: arch_timer: Fix resource leak on error path Date: Thu, 24 Oct 2019 18:27:45 +0800 Message-Id: <1571912870-18471-3-git-send-email-shannon.zhao@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571912870-18471-1-git-send-email-shannon.zhao@linux.alibaba.com> References: <1571912870-18471-1-git-send-email-shannon.zhao@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It needs to cleanup irq setup for host_vtimer_irq when request_percpu_irq fails for host_ptimer_irq. It needs to cleanup irq setup for both host_vtimer_irq and host_ptimer_irq when seeting vcpu affinity error as well. Fixes: 9e01dc76be6a ("KVM: arm/arm64: arch_timer: Assign the phys timer on VHE systems") Signed-off-by: Shannon Zhao --- virt/kvm/arm/arch_timer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index e2bb5bd..f5a5d51 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -960,7 +960,7 @@ int kvm_timer_hyp_init(bool has_gic) if (err) { kvm_err("kvm_arch_timer: can't request ptimer interrupt %d (%d)\n", host_ptimer_irq, err); - return err; + goto out_free_irq; } if (has_gic) { @@ -968,7 +968,7 @@ int kvm_timer_hyp_init(bool has_gic) kvm_get_running_vcpus()); if (err) { kvm_err("kvm_arch_timer: error setting vcpu affinity\n"); - goto out_free_irq; + goto out_free_pirq; } } @@ -984,6 +984,8 @@ int kvm_timer_hyp_init(bool has_gic) "kvm/arm/timer:starting", kvm_timer_starting_cpu, kvm_timer_dying_cpu); return 0; +out_free_pirq: + free_percpu_irq(host_ptimer_irq, kvm_get_running_vcpus()); out_free_irq: free_percpu_irq(host_vtimer_irq, kvm_get_running_vcpus()); return err; -- 1.8.3.1