]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/nouveau/nvif: Fix potential memory leak in nvif_vmm_ctor().
authorFanhua Li <lifanhua5@huawei.com>
Mon, 28 Jul 2025 11:50:27 +0000 (19:50 +0800)
committerDanilo Krummrich <dakr@kernel.org>
Sat, 9 Aug 2025 12:09:53 +0000 (14:09 +0200)
When the nvif_vmm_type is invalid, we will return error directly
without freeing the args in nvif_vmm_ctor(), which leading a memory
leak. Fix it by setting the ret -EINVAL and goto done.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/all/202312040659.4pJpMafN-lkp@intel.com/
Fixes: 6b252cf42281 ("drm/nouveau: nvkm/vmm: implement raw ops to manage uvmm")
Signed-off-by: Fanhua Li <lifanhua5@huawei.com>
Link: https://lore.kernel.org/r/20250728115027.50878-1-lifanhua5@huawei.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
drivers/gpu/drm/nouveau/nvif/vmm.c

index 99296f03371ae06998f165d69cbb9b0096e26a2d..07c1ebc2a94141d1964aa742307e5b244becd9cf 100644 (file)
@@ -219,7 +219,8 @@ nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass,
        case RAW: args->type = NVIF_VMM_V0_TYPE_RAW; break;
        default:
                WARN_ON(1);
-               return -EINVAL;
+               ret = -EINVAL;
+               goto done;
        }
 
        memcpy(args->data, argv, argc);