lkml.org 
[lkml]   [2019]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/3] drm/ttm: Reset num_zones on ttm_mem_global cleanup
Date
num_zones in the ttm_mem_global structure was never reset after calling
ttm_mem_global_release(). Consequently, when multiple GPU drivers
are loaded, and the first one fails to load its firmware, the second
driver will attempt to load its own firmware. Initializing the
second driver invokes ttm_mem_global_init where ttm_mem_global.num_zones
is eventually incremented beyond TTM_MEM_MAX_ZONES.
ttm_mem_global.num_zones is then used to dereference a ttm_mem_zone beyond
the amount of ttm_mem_zones allocated, resulting in a crash.

Signed-off-by: Brian Yip <itsbriany@gmail.com>
---
drivers/gpu/drm/ttm/ttm_memory.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 699fed9e08ee..55ccb9800893 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -478,6 +478,9 @@ void ttm_mem_global_release(struct ttm_mem_global *glob)
}
kobject_del(&glob->kobj);
kobject_put(&glob->kobj);
+
+ if (!kref_read(&glob->kobj.kref))
+ glob->num_zones = 0;
}

static void ttm_check_swapping(struct ttm_mem_global *glob)
--
2.20.1
\
 
 \ /
  Last update: 2019-04-15 01:38    [W:0.057 / U:37.284 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site