Skip to contentSkip to conversation

drm/vc4: Return -EFAULT on copy_from_user() failure

PATCH In review Dan Carpenter 2 participants 2 messages Mar 8, 2016 – Mar 14, 2016

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

PATCH 1/1 drm/vc4: Return -EFAULT on copy_from_user() failure

The copy_from_user() function returns the number of bytes not copied but we want to return a negative error code.

Fixes 463873d57014 ('drm/vc4: Add an API for creating GPU shaders in GEM BOs.')
drivers/gpu/drm/vc4/vc4_bo.c +4 -3
index 034ef2d..9807bc9 100644
@@ -498,11 +498,12 @@ vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
 	if (IS_ERR(bo))
 		return PTR_ERR(bo);
 
-	ret = copy_from_user(bo->base.vaddr,
+	if (copy_from_user(bo->base.vaddr,
 			     (void __user *)(uintptr_t)args->data,
-			     args->size);
-	if (ret != 0)
+			     args->size)) {
+		ret = -EFAULT;
 		goto fail;
+	}
 	/* Clear the rest of the memory from allocating from the BO
 	 * cache.
 	 */
#1 lore raw
Quoted 5 lines · Dan Carpenter

The copy_from_user() function returns the number of bytes not copied but we want to return a negative error code.

Fixes 463873d57014 ('drm/vc4: Add an API for creating GPU shaders in GEM BOs.')

Pulled. Thanks!