The correct helper for taking an f_count reference is get_file(). Use it and check results.
Signed-off-by: Kees Cook <keesc...@chromium.org> --- Cc: Jani Nikula <jani.nik...@linux.intel.com> Cc: Joonas Lahtinen <joonas.lahti...@linux.intel.com> Cc: Rodrigo Vivi <rodrigo.v...@intel.com> Cc: Tvrtko Ursulin <tursu...@ursulin.net> Cc: David Airlie <airl...@gmail.com> Cc: Daniel Vetter <dan...@ffwll.ch> Cc: Andi Shyti <andi.sh...@linux.intel.com> Cc: Lucas De Marchi <lucas.demar...@intel.com> Cc: Matt Atwood <matthew.s.atw...@intel.com> Cc: Matthew Auld <matthew.a...@intel.com> Cc: Nirmoy Das <nirmoy....@intel.com> Cc: Jonathan Cavitt <jonathan.cav...@intel.com> Cc: intel-...@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/i915/gt/shmem_utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c index bccc3a1200bc..dc25e6dc884b 100644 --- a/drivers/gpu/drm/i915/gt/shmem_utils.c +++ b/drivers/gpu/drm/i915/gt/shmem_utils.c @@ -38,8 +38,9 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj) void *ptr; if (i915_gem_object_is_shmem(obj)) { - file = obj->base.filp; - atomic_long_inc(&file->f_count); + file = get_file(obj->base.filp); + if (!file) + return ERR_PTR(-ESRCH); return file; } -- 2.34.1