Fix oops in GEM object allocation
authorThomas White <taw@bitwiz.org.uk>
Mon, 9 Nov 2009 21:01:52 +0000 (22:01 +0100)
committerThomas White <taw@bitwiz.org.uk>
Mon, 9 Nov 2009 21:01:52 +0000 (22:01 +0100)
If the allocation of a new GEM object failed due to there being no available VRAM, then
glamo_gem_object_alloc() would bail out, calling drm_gem_object_unreference() in the
process.  glamodrm_gem_free_object() would then proceed to try to give back the memory
which was unsuccessfully allocated.  This obviously doesn't work, and resulted in an oops.
To fix it, check that the VRAM block handle is non-NULL before freeing it.

Signed-off-by: Thomas White <taw@bitwiz.org.uk>
drivers/mfd/glamo/glamo-buffer.c

index e1c973c..a6d085f 100644 (file)
@@ -319,7 +319,9 @@ void glamodrm_gem_free_object(struct drm_gem_object *obj)
        gobj = obj->driver_private;
 
        /* Free the VRAM */
-       drm_mm_put_block(gobj->block);
+       if ( gobj->block != NULL ) {
+               drm_mm_put_block(gobj->block);
+       }
 
        /* Release mappings */
        list = &obj->map_list;