On 11/23/26 9:50 PM, Dave Airlie via B4 Relay wrote: > From: Dave Airlie <[email protected]>... > @@ -3446,9 +3483,11 @@ nvkm_device_ctor(const struct nvkm_device_func *func, > > ret = nvkm_intr_install(device); > done: > - if (ret && device->pri) { > - iounmap(device->pri); > - device->pri = NULL; > + if (ret) { > + /* Unwind the partially constructed device, so that the caller > + * only has to release the resources it allocated itself. > + */ > + nvkm_device_dtor(device);
This also fixes a user-after-free on Tegra (not just a leak), because struct nvkm_device_tegra embeds a struct nvkm_device by value. In other words, if nvkm_device_ctor() fails after adding the device to the nv_devices list, nvkm_device_tegra_new() frees tdev while tdev->device is still on that list, so the next nvkm_device_find_locked() call would read freed memory. I'm not sure how important that is, but if it matters, then splitting the fix back into its own patch might be the way to go here, after all. thanks, -- John Hubbard
