drm/ttm: Don't leak a resource on swapout move error
authorjsg <jsg@openbsd.org>
Wed, 26 Jul 2023 06:40:47 +0000 (06:40 +0000)
committerjsg <jsg@openbsd.org>
Wed, 26 Jul 2023 06:40:47 +0000 (06:40 +0000)
From Thomas Hellstrom
f037f6038736bd038ddb9c72de979a08cc1ee3b5 in linux-6.1.y/6.1.40
a590f03d8de7c4cb7ce4916dc7f2fd10711faabe in mainline linux

sys/dev/pci/drm/ttm/ttm_bo.c

index 994c67f..ca0d0bf 100644 (file)
@@ -1191,6 +1191,7 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,
                ret = ttm_bo_handle_move_mem(bo, evict_mem, true, &ctx, &hop);
                if (unlikely(ret != 0)) {
                        WARN(ret == -EMULTIHOP, "Unexpected multihop in swaput - likely driver bug.\n");
+                       ttm_resource_free(bo, &evict_mem);
                        goto out;
                }
        }