[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADnq5_OFhh_-qn9DdKWM5mhRWKfHWX027K95qyBUsqUao6vwHg@mail.gmail.com>
Date: Thu, 14 Dec 2023 12:09:14 -0500
From: Alex Deucher <alexdeucher@...il.com>
To: Zhipeng Lu <alexious@....edu.cn>
Cc: "Pan, Xinhui" <Xinhui.Pan@....com>, linux-kernel@...r.kernel.org,
amd-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
Alex Deucher <alexander.deucher@....com>,
Christian König <christian.koenig@....com>
Subject: Re: [PATCH] gpu/drm/radeon: fix two memleaks in radeon_vm_init
Applied. Thanks!
On Thu, Dec 14, 2023 at 11:59 AM Zhipeng Lu <alexious@....edu.cn> wrote:
>
> When radeon_bo_create and radeon_vm_clear_bo fail, the vm->page_tables
> allocated before need to be freed. However, neither radeon_vm_init
> itself nor its caller have done such deallocation.
>
> Fixes: 6d2f2944e95e ("drm/radeon: use normal BOs for the page tables v4")
> Signed-off-by: Zhipeng Lu <alexious@....edu.cn>
> ---
> drivers/gpu/drm/radeon/radeon_vm.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
> index 987cabbf1318..c38b4d5d6a14 100644
> --- a/drivers/gpu/drm/radeon/radeon_vm.c
> +++ b/drivers/gpu/drm/radeon/radeon_vm.c
> @@ -1204,13 +1204,17 @@ int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm)
> r = radeon_bo_create(rdev, pd_size, align, true,
> RADEON_GEM_DOMAIN_VRAM, 0, NULL,
> NULL, &vm->page_directory);
> - if (r)
> + if (r) {
> + kfree(vm->page_tables);
> + vm->page_tables = NULL;
> return r;
> -
> + }
> r = radeon_vm_clear_bo(rdev, vm->page_directory);
> if (r) {
> radeon_bo_unref(&vm->page_directory);
> vm->page_directory = NULL;
> + kfree(vm->page_tables);
> + vm->page_tables = NULL;
> return r;
> }
>
> --
> 2.34.1
>
Powered by blists - more mailing lists