From: jsg Date: Fri, 4 Aug 2023 08:57:11 +0000 (+0000) Subject: drm/ttm: Don't leak a resource on eviction error X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9e45a55183d90fcb138e67e6d31863f5733e2bf9;p=openbsd drm/ttm: Don't leak a resource on eviction error From Thomas Hellstrom e9c44738cb1f537b177cc1beabcf6913690460cd in linux-6.1.y/6.1.43 e8188c461ee015ba0b9ab2fc82dbd5ebca5a5532 in mainline linux --- diff --git a/sys/dev/pci/drm/ttm/ttm_bo.c b/sys/dev/pci/drm/ttm/ttm_bo.c index a7f50714c72..48476da8e07 100644 --- a/sys/dev/pci/drm/ttm/ttm_bo.c +++ b/sys/dev/pci/drm/ttm/ttm_bo.c @@ -499,18 +499,18 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, goto out; } -bounce: - ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); - if (ret == -EMULTIHOP) { + do { + ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); + if (ret != -EMULTIHOP) + break; + ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); - if (ret) { - if (ret != -ERESTARTSYS && ret != -EINTR) - pr_err("Buffer eviction failed\n"); - ttm_resource_free(bo, &evict_mem); - goto out; - } - /* try and move to final place now. */ - goto bounce; + } while (!ret); + + if (ret) { + ttm_resource_free(bo, &evict_mem); + if (ret != -ERESTARTSYS && ret != -EINTR) + pr_err("Buffer eviction failed\n"); } out: return ret;