Skip to content

Commit ef87557

Browse files
author
Thomas Hellström
committed
drm/xe: Don't use __user error pointers
The error pointer macros are not aware of __user pointers and as a consequence sparse warns. Have the copy_mask() function return an integer instead of a __user pointer. Fixes: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs") Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240117134048.165425-5-thomas.hellstrom@linux.intel.com (cherry picked from commit 78366ee) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
1 parent 3ecf036 commit ef87557

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

drivers/gpu/drm/xe/xe_query.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -459,21 +459,21 @@ static size_t calc_topo_query_size(struct xe_device *xe)
459459
sizeof_field(struct xe_gt, fuse_topo.eu_mask_per_dss));
460460
}
461461

462-
static void __user *copy_mask(void __user *ptr,
463-
struct drm_xe_query_topology_mask *topo,
464-
void *mask, size_t mask_size)
462+
static int copy_mask(void __user **ptr,
463+
struct drm_xe_query_topology_mask *topo,
464+
void *mask, size_t mask_size)
465465
{
466466
topo->num_bytes = mask_size;
467467

468-
if (copy_to_user(ptr, topo, sizeof(*topo)))
469-
return ERR_PTR(-EFAULT);
470-
ptr += sizeof(topo);
468+
if (copy_to_user(*ptr, topo, sizeof(*topo)))
469+
return -EFAULT;
470+
*ptr += sizeof(topo);
471471

472-
if (copy_to_user(ptr, mask, mask_size))
473-
return ERR_PTR(-EFAULT);
474-
ptr += mask_size;
472+
if (copy_to_user(*ptr, mask, mask_size))
473+
return -EFAULT;
474+
*ptr += mask_size;
475475

476-
return ptr;
476+
return 0;
477477
}
478478

479479
static int query_gt_topology(struct xe_device *xe,
@@ -493,28 +493,28 @@ static int query_gt_topology(struct xe_device *xe,
493493
}
494494

495495
for_each_gt(gt, xe, id) {
496+
int err;
497+
496498
topo.gt_id = id;
497499

498500
topo.type = DRM_XE_TOPO_DSS_GEOMETRY;
499-
query_ptr = copy_mask(query_ptr, &topo,
500-
gt->fuse_topo.g_dss_mask,
501-
sizeof(gt->fuse_topo.g_dss_mask));
502-
if (IS_ERR(query_ptr))
503-
return PTR_ERR(query_ptr);
501+
err = copy_mask(&query_ptr, &topo, gt->fuse_topo.g_dss_mask,
502+
sizeof(gt->fuse_topo.g_dss_mask));
503+
if (err)
504+
return err;
504505

505506
topo.type = DRM_XE_TOPO_DSS_COMPUTE;
506-
query_ptr = copy_mask(query_ptr, &topo,
507-
gt->fuse_topo.c_dss_mask,
508-
sizeof(gt->fuse_topo.c_dss_mask));
509-
if (IS_ERR(query_ptr))
510-
return PTR_ERR(query_ptr);
507+
err = copy_mask(&query_ptr, &topo, gt->fuse_topo.c_dss_mask,
508+
sizeof(gt->fuse_topo.c_dss_mask));
509+
if (err)
510+
return err;
511511

512512
topo.type = DRM_XE_TOPO_EU_PER_DSS;
513-
query_ptr = copy_mask(query_ptr, &topo,
514-
gt->fuse_topo.eu_mask_per_dss,
515-
sizeof(gt->fuse_topo.eu_mask_per_dss));
516-
if (IS_ERR(query_ptr))
517-
return PTR_ERR(query_ptr);
513+
err = copy_mask(&query_ptr, &topo,
514+
gt->fuse_topo.eu_mask_per_dss,
515+
sizeof(gt->fuse_topo.eu_mask_per_dss));
516+
if (err)
517+
return err;
518518
}
519519

520520
return 0;

0 commit comments

Comments
 (0)