mirror of https://gitee.com/openkylin/linux.git
drm: Use ENOENT consistently for the error return for an unmatched handle.
This is consistent with trying to access a filename that not exist within a directory which is a good analogy here. The main reason for the change is that it is easy to confuse the error code of EBADF as an performing an ioctl on an invalid file descriptor (rather than an unknown object). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
a44d2f3725
commit
bf79cb914d
|
@ -322,7 +322,7 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
|
|||
|
||||
obj = drm_gem_object_lookup(dev, file_priv, args->handle);
|
||||
if (obj == NULL)
|
||||
return -EBADF;
|
||||
return -ENOENT;
|
||||
|
||||
again:
|
||||
if (idr_pre_get(&dev->object_name_idr, GFP_KERNEL) == 0) {
|
||||
|
|
|
@ -456,7 +456,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
|
|||
|
||||
obj = drm_gem_object_lookup(dev, file_priv, args->handle);
|
||||
if (obj == NULL)
|
||||
return -EBADF;
|
||||
return -ENOENT;
|
||||
obj_priv = to_intel_bo(obj);
|
||||
|
||||
/* Bounds check source.
|
||||
|
@ -919,7 +919,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
|
|||
|
||||
obj = drm_gem_object_lookup(dev, file_priv, args->handle);
|
||||
if (obj == NULL)
|
||||
return -EBADF;
|
||||
return -ENOENT;
|
||||
obj_priv = to_intel_bo(obj);
|
||||
|
||||
/* Bounds check destination.
|
||||
|
@ -1002,7 +1002,7 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
|
|||
|
||||
obj = drm_gem_object_lookup(dev, file_priv, args->handle);
|
||||
if (obj == NULL)
|
||||
return -EBADF;
|
||||
return -ENOENT;
|
||||
obj_priv = to_intel_bo(obj);
|
||||
|
||||
mutex_lock(&dev->struct_mutex);
|
||||
|
@ -1060,7 +1060,7 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
|
|||
obj = drm_gem_object_lookup(dev, file_priv, args->handle);
|
||||
if (obj == NULL) {
|
||||
mutex_unlock(&dev->struct_mutex);
|
||||
return -EBADF;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
#if WATCH_BUF
|
||||
|
@ -1099,7 +1099,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
|
|||
|
||||
obj = drm_gem_object_lookup(dev, file_priv, args->handle);
|
||||
if (obj == NULL)
|
||||
return -EBADF;
|
||||
return -ENOENT;
|
||||
|
||||
offset = args->offset;
|
||||
|
||||
|
@ -1373,7 +1373,7 @@ i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
|
|||
|
||||
obj = drm_gem_object_lookup(dev, file_priv, args->handle);
|
||||
if (obj == NULL)
|
||||
return -EBADF;
|
||||
return -ENOENT;
|
||||
|
||||
mutex_lock(&dev->struct_mutex);
|
||||
|
||||
|
@ -3364,7 +3364,7 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
|
|||
reloc->target_handle);
|
||||
if (target_obj == NULL) {
|
||||
i915_gem_object_unpin(obj);
|
||||
return -EBADF;
|
||||
return -ENOENT;
|
||||
}
|
||||
target_obj_priv = to_intel_bo(target_obj);
|
||||
|
||||
|
@ -3781,7 +3781,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
|
|||
exec_list[i].handle, i);
|
||||
/* prevent error path from reading uninitialized data */
|
||||
args->buffer_count = i + 1;
|
||||
ret = -EBADF;
|
||||
ret = -ENOENT;
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -3791,7 +3791,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
|
|||
object_list[i]);
|
||||
/* prevent error path from reading uninitialized data */
|
||||
args->buffer_count = i + 1;
|
||||
ret = -EBADF;
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
obj_priv->in_execbuffer = true;
|
||||
|
@ -4265,7 +4265,7 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data,
|
|||
DRM_ERROR("Bad handle in i915_gem_pin_ioctl(): %d\n",
|
||||
args->handle);
|
||||
mutex_unlock(&dev->struct_mutex);
|
||||
return -EBADF;
|
||||
return -ENOENT;
|
||||
}
|
||||
obj_priv = to_intel_bo(obj);
|
||||
|
||||
|
@ -4321,7 +4321,7 @@ i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
|
|||
DRM_ERROR("Bad handle in i915_gem_unpin_ioctl(): %d\n",
|
||||
args->handle);
|
||||
mutex_unlock(&dev->struct_mutex);
|
||||
return -EBADF;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
obj_priv = to_intel_bo(obj);
|
||||
|
@ -4355,7 +4355,7 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
|
|||
if (obj == NULL) {
|
||||
DRM_ERROR("Bad handle in i915_gem_busy_ioctl(): %d\n",
|
||||
args->handle);
|
||||
return -EBADF;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
mutex_lock(&dev->struct_mutex);
|
||||
|
@ -4408,7 +4408,7 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
|
|||
if (obj == NULL) {
|
||||
DRM_ERROR("Bad handle in i915_gem_madvise_ioctl(): %d\n",
|
||||
args->handle);
|
||||
return -EBADF;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
mutex_lock(&dev->struct_mutex);
|
||||
|
|
|
@ -275,7 +275,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
|
|||
|
||||
obj = drm_gem_object_lookup(dev, file_priv, args->handle);
|
||||
if (obj == NULL)
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
obj_priv = to_intel_bo(obj);
|
||||
|
||||
if (!i915_tiling_ok(dev, args->stride, obj->size, args->tiling_mode)) {
|
||||
|
@ -362,7 +362,7 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
|
|||
|
||||
obj = drm_gem_object_lookup(dev, file_priv, args->handle);
|
||||
if (obj == NULL)
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
obj_priv = to_intel_bo(obj);
|
||||
|
||||
mutex_lock(&dev->struct_mutex);
|
||||
|
|
|
@ -284,7 +284,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
|
|||
if (!gem) {
|
||||
NV_ERROR(dev, "Unknown handle 0x%08x\n", b->handle);
|
||||
validate_fini(op, NULL);
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
}
|
||||
nvbo = gem->driver_private;
|
||||
|
||||
|
@ -759,7 +759,7 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data,
|
|||
|
||||
gem = drm_gem_object_lookup(dev, file_priv, req->handle);
|
||||
if (!gem)
|
||||
return ret;
|
||||
return -ENOENT;
|
||||
nvbo = nouveau_gem_object(gem);
|
||||
|
||||
if (nvbo->cpu_filp) {
|
||||
|
@ -797,7 +797,7 @@ nouveau_gem_ioctl_cpu_fini(struct drm_device *dev, void *data,
|
|||
|
||||
gem = drm_gem_object_lookup(dev, file_priv, req->handle);
|
||||
if (!gem)
|
||||
return ret;
|
||||
return -ENOENT;
|
||||
nvbo = nouveau_gem_object(gem);
|
||||
|
||||
if (nvbo->cpu_filp != file_priv)
|
||||
|
@ -822,7 +822,7 @@ nouveau_gem_ioctl_info(struct drm_device *dev, void *data,
|
|||
|
||||
gem = drm_gem_object_lookup(dev, file_priv, req->handle);
|
||||
if (!gem)
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
|
||||
ret = nouveau_gem_info(gem, req);
|
||||
drm_gem_object_unreference_unlocked(gem);
|
||||
|
|
|
@ -917,7 +917,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
|
|||
|
||||
gem = drm_gem_object_lookup(dev, file_priv, buffer_handle);
|
||||
if (!gem)
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
cursor = nouveau_gem_object(gem);
|
||||
|
||||
ret = nouveau_bo_map(cursor);
|
||||
|
|
|
@ -365,7 +365,7 @@ nv50_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
|
|||
|
||||
gem = drm_gem_object_lookup(dev, file_priv, buffer_handle);
|
||||
if (!gem)
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
cursor = nouveau_gem_object(gem);
|
||||
|
||||
ret = nouveau_bo_map(cursor);
|
||||
|
|
|
@ -72,7 +72,7 @@ int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
|
|||
if (p->relocs[i].gobj == NULL) {
|
||||
DRM_ERROR("gem object lookup failed 0x%x\n",
|
||||
r->handle);
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
}
|
||||
p->relocs_ptr[i] = &p->relocs[i];
|
||||
p->relocs[i].robj = p->relocs[i].gobj->driver_private;
|
||||
|
|
|
@ -170,7 +170,7 @@ int radeon_crtc_cursor_set(struct drm_crtc *crtc,
|
|||
obj = drm_gem_object_lookup(crtc->dev, file_priv, handle);
|
||||
if (!obj) {
|
||||
DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, radeon_crtc->crtc_id);
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
ret = radeon_gem_object_pin(obj, RADEON_GEM_DOMAIN_VRAM, &gpu_addr);
|
||||
|
|
|
@ -226,7 +226,7 @@ int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
|
|||
/* just do a BO wait for now */
|
||||
gobj = drm_gem_object_lookup(dev, filp, args->handle);
|
||||
if (gobj == NULL) {
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
}
|
||||
robj = gobj->driver_private;
|
||||
|
||||
|
@ -245,7 +245,7 @@ int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
|
|||
|
||||
gobj = drm_gem_object_lookup(dev, filp, args->handle);
|
||||
if (gobj == NULL) {
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
}
|
||||
robj = gobj->driver_private;
|
||||
args->addr_ptr = radeon_bo_mmap_offset(robj);
|
||||
|
@ -264,7 +264,7 @@ int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
|
|||
|
||||
gobj = drm_gem_object_lookup(dev, filp, args->handle);
|
||||
if (gobj == NULL) {
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
}
|
||||
robj = gobj->driver_private;
|
||||
r = radeon_bo_wait(robj, &cur_placement, true);
|
||||
|
@ -294,7 +294,7 @@ int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
|
|||
|
||||
gobj = drm_gem_object_lookup(dev, filp, args->handle);
|
||||
if (gobj == NULL) {
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
}
|
||||
robj = gobj->driver_private;
|
||||
r = radeon_bo_wait(robj, NULL, false);
|
||||
|
@ -316,7 +316,7 @@ int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
|
|||
DRM_DEBUG("%d \n", args->handle);
|
||||
gobj = drm_gem_object_lookup(dev, filp, args->handle);
|
||||
if (gobj == NULL)
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
robj = gobj->driver_private;
|
||||
r = radeon_bo_set_tiling_flags(robj, args->tiling_flags, args->pitch);
|
||||
drm_gem_object_unreference_unlocked(gobj);
|
||||
|
@ -334,7 +334,7 @@ int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
|
|||
DRM_DEBUG("\n");
|
||||
gobj = drm_gem_object_lookup(dev, filp, args->handle);
|
||||
if (gobj == NULL)
|
||||
return -EINVAL;
|
||||
return -ENOENT;
|
||||
rbo = gobj->driver_private;
|
||||
r = radeon_bo_reserve(rbo, false);
|
||||
if (unlikely(r != 0))
|
||||
|
|
Loading…
Reference in New Issue