Re: [PATCH] drm/amdgpu/userq: fix memory leak in MQD creation error paths
From: Junrui Luo
Date: Sun Mar 15 2026 - 01:25:27 EST
On Sat, Mar 14, 2026 at 09:04:08PM +0100, Markus Elfring wrote:
> …
> > Fix by adding kfree() before each goto free_mqd on VA validation
> > failure in the COMPUTE, GFX, and SDMA branches.
>
> How do you think about to benefit any more from application of an attribute
> like __free(kfree)?
> https://elixir.bootlin.com/linux/v7.0-rc3/source/include/linux/cleanup.h#L157-L161
Hi Markus,
Thanks for the suggestion. I considered __free(kfree) but the cleanup.h
comment says scope-based cleanup and "goto" should not be mixed in the same
function. Since mes_userq_mqd_create() relies heavily on goto-based
unwinding, applying __free(kfree) only to the memdup pointers would
violate that guideline.
A full conversion to scope-based cleanup would require restructuring
the entire function, which seems beyond the scope of a bug fix.
Thanks,
Junrui Luo