]> git.baikalelectronics.ru Git - kernel.git/commit
drm/nouveau: avoid a use-after-free when BO init fails
authorJeremy Cline <jcline@redhat.com>
Thu, 3 Dec 2020 00:02:20 +0000 (19:02 -0500)
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Wed, 6 Oct 2021 09:12:29 +0000 (11:12 +0200)
commit96a048225334bf65617e17386eb5eacf56b10d4c
treeb9cced79945c926d9907481edae51fbdd4c595df
parent58abed1a544785c5cef78ca08f2bf6e34d1b2283
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: a65fdc4451ac ("drm/nouveau: Initialize GEM object before TTM object")
Cc: Thierry Reding <treding@nvidia.com>
Signed-off-by: Jeremy Cline <jcline@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201203000220.18238-1-jcline@redhat.com
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
drivers/gpu/drm/nouveau/nouveau_gem.c