[PATCH v2 1/3] drm/nouveau: fix error path in nvkm_gsp_fwsec_v2
Timur Tabi
ttabi at nvidia.com
Mon Aug 11 22:16:25 UTC 2025
On Sat, 2025-08-09 at 13:26 +0200, Danilo Krummrich wrote:
> > + if (!fw->boot)
> > + return -ENOMEM;
>
> Good catch! It's also good that you moved the return below the
> nvkm_firmware_put() call.
>
> But don't we also need to revert the preceding call to nvkm_falcon_fw_ctor()?
I don't know. I cannot decipher Nouveau's cleanup code.
If it does need to be reverted, then we have that problem in a lot of places, in both
nvkm_gsp_fwsec_v2() and nvkm_gsp_fwsec_v3().
At one point Ben told me that Nouveau cleans itself up on failure, eliminating the need to clean up
on every "return ret" exit. You can see this through fwsec.c -- none of the return-error calls do
any cleanup.
I tried to test this, but I didn't get far. I modified nvkm_gsp_fwsec_v2 to return failure and did
a trace of nvkm_falcon_fw_ctor() and nvkm_falcon_fw_ctor(), and this is what I found:
[ 1281.361048] nvkm_falcon_fw_ctor::204 fw=ffff8e898022f540 (null)
[ 1281.367036] nvkm_falcon_fw_ctor::204 fw=ffff8e898022f640 (null)
[ 1281.379502] nvkm_falcon_fw_ctor::204 fw=ffffcfc3408e7908 (null)
[ 1281.422846] nvkm_falcon_fw_dtor::157 fw=ffff8e89812480d0 (null)
[ 1281.429326] nvkm_falcon_fw_dtor::157 fw=ffff8e898022f640 booter-unload
[ 1281.435884] nvkm_falcon_fw_dtor::157 fw=ffff8e898022f540 booter-load
What's throwing me off is:
[ 1281.379502] nvkm_falcon_fw_ctor::204 fw=ffffcfc3408e7908 (null)
[ 1281.422846] nvkm_falcon_fw_dtor::157 fw=ffff8e89812480d0 (null)
These two should match. For some reason, there is no dtor call for 7908, but more disturbingly,
there is no ctor call for 80d0. This doesn't happen if nvkm_gsp_fwsec_v2 succeeds.
More information about the Nouveau
mailing list