drm/i915: memory leak in __i915_gem_vma_create()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 18 Mar 2015 08:21:58 +0000 (11:21 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 20 Mar 2015 10:48:12 +0000 (11:48 +0100)
In the original code then if WARN_ON(i915_is_ggtt(vm) != !!ggtt_view)
was true then we leak "vma".  Presumably that doesn't happen often but
static checkers complain and this bug is easy to fix.

Fixes: c3bbb6f2825d ('drm/i915: Do not use ggtt_view with (aliasing) PPGTT')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_gem_gtt.c

index f1b9ea61de4bdad515a9f95413ead02f0bb64117..cbf013fd6b984dc63659b66544adc1d7eb80a777 100644 (file)
@@ -2340,12 +2340,13 @@ __i915_gem_vma_create(struct drm_i915_gem_object *obj,
                      struct i915_address_space *vm,
                      const struct i915_ggtt_view *ggtt_view)
 {
-       struct i915_vma *vma = kzalloc(sizeof(*vma), GFP_KERNEL);
-       if (vma == NULL)
-               return ERR_PTR(-ENOMEM);
+       struct i915_vma *vma;
 
        if (WARN_ON(i915_is_ggtt(vm) != !!ggtt_view))
                return ERR_PTR(-EINVAL);
+       vma = kzalloc(sizeof(*vma), GFP_KERNEL);
+       if (vma == NULL)
+               return ERR_PTR(-ENOMEM);
 
        INIT_LIST_HEAD(&vma->vma_link);
        INIT_LIST_HEAD(&vma->mm_list);