]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/ttm/nouveau: don't call tt destroy callback on alloc failure.
authorDave Airlie <airlied@redhat.com>
Tue, 28 Jul 2020 04:17:36 +0000 (14:17 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Aug 2020 06:24:15 +0000 (08:24 +0200)
commit 5de5b6ecf97a021f29403aa272cb4e03318ef586 upstream.

This is confusing, and from my reading of all the drivers only
nouveau got this right.

Just make the API act under driver control of it's own allocation
failing, and don't call destroy, if the page table fails to
create there is nothing to cleanup here.

(I'm willing to believe I've missed something here, so please
review deeply).

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200728041736.20689-1-airlied@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/nouveau/nouveau_sgdma.c
drivers/gpu/drm/ttm/ttm_tt.c

index feaac908efed34af942faaadd35ff08e6f09c636..34403b810dbac31401ed5ea17d380e56909277a3 100644 (file)
@@ -96,12 +96,9 @@ nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, uint32_t page_flags)
        else
                nvbe->ttm.ttm.func = &nv50_sgdma_backend;
 
-       if (ttm_dma_tt_init(&nvbe->ttm, bo, page_flags))
-               /*
-                * A failing ttm_dma_tt_init() will call ttm_tt_destroy()
-                * and thus our nouveau_sgdma_destroy() hook, so we don't need
-                * to free nvbe here.
-                */
+       if (ttm_dma_tt_init(&nvbe->ttm, bo, page_flags)) {
+               kfree(nvbe);
                return NULL;
+       }
        return &nvbe->ttm.ttm;
 }
index 2ec448e1d663dc452084b043584dec359ed4ea29..9f296b9da05bd56d2ab7879f317fc046cf2ab443 100644 (file)
@@ -242,7 +242,6 @@ int ttm_tt_init(struct ttm_tt *ttm, struct ttm_buffer_object *bo,
        ttm_tt_init_fields(ttm, bo, page_flags);
 
        if (ttm_tt_alloc_page_directory(ttm)) {
-               ttm_tt_destroy(ttm);
                pr_err("Failed allocating page table\n");
                return -ENOMEM;
        }
@@ -266,7 +265,6 @@ int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_buffer_object *bo,
 
        INIT_LIST_HEAD(&ttm_dma->pages_list);
        if (ttm_dma_tt_alloc_page_directory(ttm_dma)) {
-               ttm_tt_destroy(ttm);
                pr_err("Failed allocating page table\n");
                return -ENOMEM;
        }
@@ -288,7 +286,6 @@ int ttm_sg_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_buffer_object *bo,
        else
                ret = ttm_dma_tt_alloc_page_directory(ttm_dma);
        if (ret) {
-               ttm_tt_destroy(ttm);
                pr_err("Failed allocating page table\n");
                return -ENOMEM;
        }