aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2009-08-20 04:29:09 -0400
committerDave Airlie <airlied@redhat.com>2009-08-20 04:58:15 -0400
commit759e4f83f418f4001e724042b4c0e408d615d9ec (patch)
tree07ad4066c90bcd88e320808c1845e017f573baa3 /drivers/gpu/drm/ttm
parent7f5f4db2d50ea1af8f160686d2e97bbfa5102b4f (diff)
drm/ttm: Fixes for "Memory accounting rework."
ttm: Fix error paths when kobject_add returns an error. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/ttm')
-rw-r--r--drivers/gpu/drm/ttm/ttm_memory.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 62fb5cf0899e..072c281a6bb5 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -244,6 +244,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
244{ 244{
245 struct ttm_mem_zone *zone = kzalloc(sizeof(*zone), GFP_KERNEL); 245 struct ttm_mem_zone *zone = kzalloc(sizeof(*zone), GFP_KERNEL);
246 uint64_t mem; 246 uint64_t mem;
247 int ret;
247 248
248 if (unlikely(!zone)) 249 if (unlikely(!zone))
249 return -ENOMEM; 250 return -ENOMEM;
@@ -259,9 +260,14 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
259 zone->used_mem = 0; 260 zone->used_mem = 0;
260 zone->glob = glob; 261 zone->glob = glob;
261 glob->zone_kernel = zone; 262 glob->zone_kernel = zone;
262 glob->zones[glob->num_zones++] = zone;
263 kobject_init(&zone->kobj, &ttm_mem_zone_kobj_type); 263 kobject_init(&zone->kobj, &ttm_mem_zone_kobj_type);
264 return kobject_add(&zone->kobj, &glob->kobj, zone->name); 264 ret = kobject_add(&zone->kobj, &glob->kobj, zone->name);
265 if (unlikely(ret != 0)) {
266 kobject_put(&zone->kobj);
267 return ret;
268 }
269 glob->zones[glob->num_zones++] = zone;
270 return 0;
265} 271}
266 272
267#ifdef CONFIG_HIGHMEM 273#ifdef CONFIG_HIGHMEM
@@ -270,6 +276,7 @@ static int ttm_mem_init_highmem_zone(struct ttm_mem_global *glob,
270{ 276{
271 struct ttm_mem_zone *zone = kzalloc(sizeof(*zone), GFP_KERNEL); 277 struct ttm_mem_zone *zone = kzalloc(sizeof(*zone), GFP_KERNEL);
272 uint64_t mem; 278 uint64_t mem;
279 int ret;
273 280
274 if (unlikely(!zone)) 281 if (unlikely(!zone))
275 return -ENOMEM; 282 return -ENOMEM;
@@ -288,9 +295,14 @@ static int ttm_mem_init_highmem_zone(struct ttm_mem_global *glob,
288 zone->used_mem = 0; 295 zone->used_mem = 0;
289 zone->glob = glob; 296 zone->glob = glob;
290 glob->zone_highmem = zone; 297 glob->zone_highmem = zone;
291 glob->zones[glob->num_zones++] = zone;
292 kobject_init(&zone->kobj, &ttm_mem_zone_kobj_type); 298 kobject_init(&zone->kobj, &ttm_mem_zone_kobj_type);
293 return kobject_add(&zone->kobj, &glob->kobj, zone->name); 299 ret = kobject_add(&zone->kobj, &glob->kobj, zone->name);
300 if (unlikely(ret != 0)) {
301 kobject_put(&zone->kobj);
302 return ret;
303 }
304 glob->zones[glob->num_zones++] = zone;
305 return 0;
294} 306}
295#else 307#else
296static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob, 308static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
@@ -298,6 +310,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
298{ 310{
299 struct ttm_mem_zone *zone = kzalloc(sizeof(*zone), GFP_KERNEL); 311 struct ttm_mem_zone *zone = kzalloc(sizeof(*zone), GFP_KERNEL);
300 uint64_t mem; 312 uint64_t mem;
313 int ret;
301 314
302 if (unlikely(!zone)) 315 if (unlikely(!zone))
303 return -ENOMEM; 316 return -ENOMEM;
@@ -327,9 +340,14 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
327 zone->used_mem = 0; 340 zone->used_mem = 0;
328 zone->glob = glob; 341 zone->glob = glob;
329 glob->zone_dma32 = zone; 342 glob->zone_dma32 = zone;
330 glob->zones[glob->num_zones++] = zone;
331 kobject_init(&zone->kobj, &ttm_mem_zone_kobj_type); 343 kobject_init(&zone->kobj, &ttm_mem_zone_kobj_type);
332 return kobject_add(&zone->kobj, &glob->kobj, zone->name); 344 ret = kobject_add(&zone->kobj, &glob->kobj, zone->name);
345 if (unlikely(ret != 0)) {
346 kobject_put(&zone->kobj);
347 return ret;
348 }
349 glob->zones[glob->num_zones++] = zone;
350 return 0;
333} 351}
334#endif 352#endif
335 353
@@ -348,8 +366,10 @@ int ttm_mem_global_init(struct ttm_mem_global *glob)
348 ret = kobject_add(&glob->kobj, 366 ret = kobject_add(&glob->kobj,
349 ttm_get_kobj(), 367 ttm_get_kobj(),
350 "memory_accounting"); 368 "memory_accounting");
351 if (unlikely(ret != 0)) 369 if (unlikely(ret != 0)) {
352 goto out_no_zone; 370 kobject_put(&glob->kobj);
371 return ret;
372 }
353 373
354 si_meminfo(&si); 374 si_meminfo(&si);
355 375