drm/i915: dereferencing an error pointer
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 17 Jul 2012 06:44:49 +0000 (09:44 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 25 Jul 2012 08:39:58 +0000 (10:39 +0200)
We need to check that "ctx" is a valid pointer before dereferencing it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_gem_context.c

index 873119f2436e59136b31edf07ee641922b4d6fea..da8b01fb1bf8dbbc1cbe34457bb67f4ff3fe28eb 100644 (file)
@@ -497,11 +497,13 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
 
        ctx = create_hw_context(dev, file_priv);
        mutex_unlock(&dev->struct_mutex);
+       if (IS_ERR(ctx))
+               return PTR_ERR(ctx);
 
        args->ctx_id = ctx->id;
        DRM_DEBUG_DRIVER("HW context %d created\n", args->ctx_id);
 
-       return PTR_RET(ctx);
+       return 0;
 }
 
 int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,