diff options
author | John Stultz <john.stultz@linaro.org> | 2021-10-13 10:22:40 -0700 |
---|---|---|
committer | Will McVicker <willmcvicker@google.com> | 2021-10-13 10:24:53 -0700 |
commit | ac745929d04f4ed9667871be470758b92931faf3 (patch) | |
tree | 7ed93445928f0cf346ea78f2fde28609026ce4ba /mali_kbase/mali_kbase_softjobs.c | |
parent | 91f48c763489fd6775dc358547c8d6f02efc02fe (diff) | |
download | gpu-ac745929d04f4ed9667871be470758b92931faf3.tar.gz |
MALI: Drop use of ksys_close(), rework fd_install usage
GregKH objected to the __close_fd() symbol being used
by the mali driver, via ksys_close(), suggesting I reach
out the the mali team as it was supposedly fixed.
In talking with the mali folks, it is not yet fixed.
The only usage is in an error path in the case that the
copy_to_user fails, where we have an fd that was created
but not passed out to userland.
Greg suggested fput/put_unused_fd() to be used instead
which requires refactoring the logic a bit (as the
kbase_sync_fence_out_create() call would return an
installed fd), so that we can only install the fd
if the copy_to_user succeeds, which matches the pattern
used elsewhere in the kernel.
Careful review would be appreciated!
Bug: 200010226
Test: boot tested on raven
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: Ia03191a32f8770cf3e9d9b30a13b18e13edb7419
Diffstat (limited to 'mali_kbase/mali_kbase_softjobs.c')
-rw-r--r-- | mali_kbase/mali_kbase_softjobs.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/mali_kbase/mali_kbase_softjobs.c b/mali_kbase/mali_kbase_softjobs.c index c76ce9d..77532ac 100644 --- a/mali_kbase/mali_kbase_softjobs.c +++ b/mali_kbase/mali_kbase_softjobs.c @@ -25,6 +25,7 @@ #include <asm/cacheflush.h> #if defined(CONFIG_SYNC) || defined(CONFIG_SYNC_FILE) #include <mali_kbase_sync.h> +#include <mali_kbase_fence.h> #endif #include <linux/dma-mapping.h> #include <uapi/gpu/arm/midgard/mali_base_kernel.h> @@ -39,6 +40,7 @@ #include <linux/sched.h> #include <linux/kernel.h> #include <linux/cache.h> +#include <linux/file.h> #if !MALI_USE_CSF /** @@ -1633,6 +1635,7 @@ int kbase_prepare_soft_job(struct kbase_jd_atom *katom) case BASE_JD_REQ_SOFT_FENCE_TRIGGER: { struct base_fence fence; + struct sync_file *sync_file; int fd; if (copy_from_user(&fence, @@ -1640,19 +1643,28 @@ int kbase_prepare_soft_job(struct kbase_jd_atom *katom) sizeof(fence)) != 0) return -EINVAL; - fd = kbase_sync_fence_out_create(katom, + sync_file = kbase_sync_fence_out_create(katom, fence.basep.stream_fd); - if (fd < 0) - return -EINVAL; + if (!sync_file) + return -ENOMEM; + + fd = get_unused_fd_flags(O_CLOEXEC); + if (fd < 0) { + fput(sync_file->file); + kbase_fence_out_remove(katom); + return fd; + } fence.basep.fd = fd; if (copy_to_user((__user void *)(uintptr_t)katom->jc, &fence, sizeof(fence)) != 0) { kbase_sync_fence_out_remove(katom); - kbase_sync_fence_close_fd(fd); + put_unused_fd(fd); + fput(sync_file->file); fence.basep.fd = -EINVAL; return -EINVAL; } + fd_install(fd, sync_file->file); } break; case BASE_JD_REQ_SOFT_FENCE_WAIT: |