Skip to contentSkip to conversation

drm/i915: dereferencing an error pointer

PATCH Applied Dan Carpenter 2 participants 2 messages Jul 17, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: dereferencing an error pointer

We need to check that "ctx" is a valid pointer before dereferencing it.

---
Applies to linux-next.

drivers/gpu/drm/i915/i915_gem_context.c +3 -1
index 9ae3f2c..a82c0ec 100644
@@ -496,11 +496,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,
#1 lore raw
Quoted 3 lines · Dan Carpenter

We need to check that "ctx" is a valid pointer before dereferencing it.

Queued for drm-intel-next, thanks for the patch.
-Daniel

Quoted 22 lines

---
Applies to linux-next.

drivers/gpu/drm/i915/i915_gem_context.c +3 -1
index 9ae3f2c..a82c0ec 100644
@@ -496,11 +496,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,
Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48