Re: [PATCH] hw/nvme: fix leak on copy ranges

Jesper Wendel Devantier <[email protected]> Mon, 03 Aug 2026 19:19:30 +0000
Newsgroups gmane.comp.emulators.qemu.block,gmane.comp.emulators.qemu,gmane.comp.emulators.qemu.stable
Message-ID <[email protected]>

On 2026-07-31T11:26:53+02:00, Klaus Jensen <[email protected]> wrote:
> From: Klaus Jensen <[email protected]>
>
> The buffer holding the ranges for the copy command is not correctly
> deallocated.
>
> Fix this.
>
> Cc: [email protected]
> Link: https://gitlab.com/qemu-project/qemu/-/work_items/4072
> Fixes: 796d20681d9b ("hw/nvme: reimplement the copy command to allow aio cancellation")
> Signed-off-by: Klaus Jensen <[email protected]>
> ---
>  hw/nvme/ctrl.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index bd6ad64b2000..aa98f7cf8048 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -2811,6 +2811,7 @@ static void nvme_copy_done(NvmeCopyAIOCB *iocb)
>  
>      qemu_iovec_destroy(&iocb->iov);
>      g_free(iocb->bounce);
> +    g_free(iocb->ranges);
>  
>      if (iocb->ret < 0) {
>          block_acct_failed(stats, &iocb->acct.read);
>
> ---
> base-commit: 0345ef676befc1a180d2f63bceaf3fca1d07ee88
> change-id: 20260731-fix-copy-ranges-leak-06242c584712
>
> Best regards,
> -- 
> Klaus Jensen <[email protected]>
>
>
>
From reading the routines operating on NvmeCopyAIOCB, this seems correct.

Reviewed-by: Jesper Wendel Devantier <[email protected]>