All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Upton <oliver.upton@linux.dev>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Marc Zyngier <maz@kernel.org>,
	Christoffer Dall <christoffer.dall@arm.com>,
	James Morse <james.morse@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] KVM: arm64: timers: Fix resource leaks in kvm_timer_hyp_init()
Date: Mon, 12 Jun 2023 07:32:52 +0000	[thread overview]
Message-ID: <ZIbKJPx2RR0Le7Zl@linux.dev> (raw)
In-Reply-To: <e0dd820f-52d2-4c54-97f3-5aa02e0bd6e0@kili.mountain>

Hi Dan,

Thanks for fixing this. Couple of small comments:

On Mon, Jun 12, 2023 at 10:07:46AM +0300, Dan Carpenter wrote:
> Smatch detected this bug:
>     arch/arm64/kvm/arch_timer.c:1425 kvm_timer_hyp_init()
>     warn: missing unwind goto?
> 
> There are a couple error paths which do not release their resources
> correctly.  Fix them.
> 
> Fixes: 9e01dc76be6a ("KVM: arm/arm64: arch_timer: Assign the phys timer on VHE systems")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  arch/arm64/kvm/arch_timer.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c
> index 05b022be885b..c2df8332d2bd 100644
> --- a/arch/arm64/kvm/arch_timer.c
> +++ b/arch/arm64/kvm/arch_timer.c
> @@ -1422,7 +1422,7 @@ int __init 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) {
> @@ -1430,7 +1430,7 @@ int __init 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_ptimer_irq;
>  			}
>  		}
>  
> @@ -1443,6 +1443,10 @@ int __init kvm_timer_hyp_init(bool has_gic)
>  	}
>  
>  	return 0;
> +
> +out_free_ptimer_irq:
> +	if (info->physical_irq > 0)
> +		free_percpu_irq(host_ptimer_irq, kvm_get_running_vcpus());

nit: we shouldn't even jump to this label in the first place if
there was no ptimer irq to set up... Maybe just drop the condition?

>  out_free_irq:

I'd prefer this label be renamed 'out_free_vtimer_irq' to make it
unambiguous.

>  	free_percpu_irq(host_vtimer_irq, kvm_get_running_vcpus());
>  	return err;
> -- 
> 2.39.2
> 

-- 
Thanks,
Oliver

  reply	other threads:[~2023-06-12  8:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12  7:07 [PATCH] KVM: arm64: timers: Fix resource leaks in kvm_timer_hyp_init() Dan Carpenter
2023-06-12  7:32 ` Oliver Upton [this message]
2023-06-12  8:00   ` Dan Carpenter
2023-06-12 19:23     ` Oliver Upton
2023-06-12 19:23       ` Oliver Upton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZIbKJPx2RR0Le7Zl@linux.dev \
    --to=oliver.upton@linux.dev \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@arm.com \
    --cc=dan.carpenter@linaro.org \
    --cc=james.morse@arm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.