0536-drm-vc4-Fix-a-couple-error-codes-in-vc4_cl_lookup_bo.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From 4c41f90e1f84c4a5c080eca03b07a0116297593b Mon Sep 17 00:00:00 2001
  2. From: Dan Carpenter <dan.carpenter@oracle.com>
  3. Date: Thu, 13 Oct 2016 11:54:31 +0300
  4. Subject: [PATCH] drm/vc4: Fix a couple error codes in vc4_cl_lookup_bos()
  5. If the allocation fails the current code returns success. If
  6. copy_from_user() fails it returns the number of bytes remaining instead
  7. of -EFAULT.
  8. Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
  9. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
  10. Reviewed-by: Eric Anholt <eric@anholt.net>
  11. (cherry picked from commit b2cdeb19f16ad984eb5bb9193f793d05a8101511)
  12. ---
  13. drivers/gpu/drm/vc4/vc4_gem.c | 9 +++++----
  14. 1 file changed, 5 insertions(+), 4 deletions(-)
  15. --- a/drivers/gpu/drm/vc4/vc4_gem.c
  16. +++ b/drivers/gpu/drm/vc4/vc4_gem.c
  17. @@ -560,14 +560,15 @@ vc4_cl_lookup_bos(struct drm_device *dev
  18. handles = drm_malloc_ab(exec->bo_count, sizeof(uint32_t));
  19. if (!handles) {
  20. + ret = -ENOMEM;
  21. DRM_ERROR("Failed to allocate incoming GEM handles\n");
  22. goto fail;
  23. }
  24. - ret = copy_from_user(handles,
  25. - (void __user *)(uintptr_t)args->bo_handles,
  26. - exec->bo_count * sizeof(uint32_t));
  27. - if (ret) {
  28. + if (copy_from_user(handles,
  29. + (void __user *)(uintptr_t)args->bo_handles,
  30. + exec->bo_count * sizeof(uint32_t))) {
  31. + ret = -EFAULT;
  32. DRM_ERROR("Failed to copy in GEM handles\n");
  33. goto fail;
  34. }