mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] KVM: PPC: Book3S HV: Free the queue pages in error path
@ 2026-09-16 11:12 Gautam Menghani
  2026-09-16 15:12 ` Amit Machhiwal
  0 siblings, 1 reply; 2+ messages in thread
From: Gautam Menghani @ 2026-09-16 11:12 UTC (permalink / raw)
  To: maddy, npiggin, mpe, chleroy, ritesh.list, sshegde, amachhiw
  Cc: linuxppc-dev, kvm, linux-kernel

If the xive_native_configure_queue() call fails, the qpage allocated is
not freed, which results in wasted memory. Fix this by freeing the qpage
in the error path.

Fixes: 5af50993850a ("KVM: PPC: Book3S HV: Native usage of the XIVE interrupt controller")
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
---
 arch/powerpc/kvm/book3s_xive.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
index 1d67237783b7..6f8648d9302b 100644
--- a/arch/powerpc/kvm/book3s_xive.c
+++ b/arch/powerpc/kvm/book3s_xive.c
@@ -961,9 +961,11 @@ static int xive_provision_queue(struct kvm_vcpu *vcpu, u8 prio)
 	 */
 	rc = xive_native_configure_queue(xc->vp_id, q, prio, qpage,
 					 xive->q_order, true);
-	if (rc)
+	if (rc) {
+		free_pages((unsigned long)qpage, xive->q_page_order);
 		pr_err("Failed to configure queue %d for VCPU %d\n",
 		       prio, xc->server_num);
+	}
 	return rc;
 }
 
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: PPC: Book3S HV: Free the queue pages in error path
  2026-09-16 11:12 [PATCH] KVM: PPC: Book3S HV: Free the queue pages in error path Gautam Menghani
@ 2026-09-16 15:12 ` Amit Machhiwal
  0 siblings, 0 replies; 2+ messages in thread
From: Amit Machhiwal @ 2026-09-16 15:12 UTC (permalink / raw)
  To: Gautam Menghani
  Cc: maddy, npiggin, mpe, chleroy, ritesh.list, sshegde, amachhiw,
	linuxppc-dev, kvm, linux-kernel

On 2026/09/16 04:42 PM, Gautam Menghani wrote:
> If the xive_native_configure_queue() call fails, the qpage allocated is
> not freed, which results in wasted memory. Fix this by freeing the qpage
> in the error path.
> 
> Fixes: 5af50993850a ("KVM: PPC: Book3S HV: Native usage of the XIVE interrupt controller")
> Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
> ---
>  arch/powerpc/kvm/book3s_xive.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
> index 1d67237783b7..6f8648d9302b 100644
> --- a/arch/powerpc/kvm/book3s_xive.c
> +++ b/arch/powerpc/kvm/book3s_xive.c
> @@ -961,9 +961,11 @@ static int xive_provision_queue(struct kvm_vcpu *vcpu, u8 prio)
>  	 */
>  	rc = xive_native_configure_queue(xc->vp_id, q, prio, qpage,
>  					 xive->q_order, true);
> -	if (rc)
> +	if (rc) {
> +		free_pages((unsigned long)qpage, xive->q_page_order);
>  		pr_err("Failed to configure queue %d for VCPU %d\n",
>  		       prio, xc->server_num);

Fix looks correct.  xive_native_configure_queue() only sets q->qpage on success,
so without this fix the cleanup path in kvmppc_xive_cleanup_vcpu() would never
reclaim the pages.  The use of q_page_order for freeing is consistent with the
rest of the file.

One nit: I would prefer emitting the error log first and then perform cleanup
which I think looks more consistent:

	if (rc) {
		pr_err("Failed to configure queue %d for VCPU %d\n",
		       prio, xc->server_num);
		free_pages((unsigned long)qpage, xive->q_page_order);
	}

Not a blocker though.

Reviewed-by: Amit Machhiwal <amachhiw@linux.ibm.com>

Thanks,
Amit

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-16 15:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 11:12 [PATCH] KVM: PPC: Book3S HV: Free the queue pages in error path Gautam Menghani
2026-09-16 15:12 ` Amit Machhiwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®