Re: [PATCH v2] ALSA: compress: Fix task resource leak on copy_to_user() failure

From: Takashi Iwai

Date: Thu Nov 19 2026 - 07:58:54 EST


On Tue, 17 Nov 2026 17:01:51 +0100,
Sreeraj S Kurup wrote:
>
> Hi Takashi,
>
> Thanks for reviewing.
>
> Regarding dma_buf_put(), get_dma_buf() takes an extra reference
> for each DMA-BUF. This reference is intended to be transferred
> to the file descriptor through fd_install(). If copy_to_user()
> fails before fd_install(), these extra references must be
> released separately.
>
> snd_compr_task_free_one() releases the task's original DMA-BUF
> references through snd_compr_task_free(). So both the explicit
> dma_buf_put() calls and snd_compr_task_free_one() are needed.
>
> Regarding the file descriptor ordering, I moved fd_install()
> after copy_to_user() so that the file descriptors are installed
> only after the task information is successfully copied to userspace.
>
> There is a small time gap between copying the descriptor numbers and
> installing the file descriptors. Userspace should use these descriptors
> only after the ioctl completes.
>
> Please let me know if you have any further concerns.
>
> Best regards,
> Sreeraj

OK, now I applied to for-next branch. Thanks.


Takashi