Skip to content

Commit bcf34aa

Browse files
jeremyclinemlankhorst
authored andcommitted
drm/nouveau: avoid a use-after-free when BO init fails
nouveau_bo_init() is backed by ttm_bo_init() and ferries its return code back to the caller. On failures, ttm_bo_init() invokes the provided destructor which should de-initialize and free the memory. Thus, when nouveau_bo_init() returns an error the gem object has already been released and the memory freed by nouveau_bo_del_ttm(). Fixes: 019cbd4 ("drm/nouveau: Initialize GEM object before TTM object") Cc: Thierry Reding <[email protected]> Signed-off-by: Jeremy Cline <[email protected]> Reviewed-by: Lyude Paul <[email protected]> Reviewed-by: Karol Herbst <[email protected]> Signed-off-by: Karol Herbst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Maarten Lankhorst <[email protected]>
1 parent b679298 commit bcf34aa

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/gpu/drm/nouveau/nouveau_gem.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,8 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int align, uint32_t domain,
247247
}
248248

249249
ret = nouveau_bo_init(nvbo, size, align, domain, NULL, NULL);
250-
if (ret) {
251-
nouveau_bo_ref(NULL, &nvbo);
250+
if (ret)
252251
return ret;
253-
}
254252

255253
/* we restrict allowed domains on nv50+ to only the types
256254
* that were requested at creation time. not possibly on

0 commit comments

Comments
 (0)