drm, i915: Fix memory leak in i915_gem_busy_ioctl().
authorRakib Mullick <rakib.mullick@gmail.com>
Tue, 15 Nov 2011 18:49:28 +0000 (00:49 +0600)
committerKeith Packard <keithp@keithp.com>
Thu, 17 Nov 2011 20:57:45 +0000 (12:57 -0800)
A call to i915_add_request() has been made in function i915_gem_busy_ioctl(). i915_add_request can fail,
so in it's exit path previously allocated memory needs to be freed.

Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
drivers/gpu/drm/i915/i915_gem.c

index ed0b68f..8359dc7 100644 (file)
@@ -3512,9 +3512,11 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
                         * so emit a request to do so.
                         */
                        request = kzalloc(sizeof(*request), GFP_KERNEL);
-                       if (request)
+                       if (request) {
                                ret = i915_add_request(obj->ring, NULL, request);
-                       else
+                               if (ret)
+                                       kfree(request);
+                       } else
                                ret = -ENOMEM;
                }