From 8676b2e65b786497c4a0609f06143e7d1bb1a3c0 Mon Sep 17 00:00:00 2001 From: Debarshi Dutta Date: Wed, 22 Aug 2018 15:55:21 +0530 Subject: gpu: nvgpu: handle return error correctly nvgpu_os_fence_syncpt_create returns ERR_PTR instead of NULL whenever its unable to construct a valid struct sync_fence instance. The current code is not handled to detect errors returned using ERR_PTR. This patch replaces the !fence check with IS_ERR() that handles the return correctly. Bug 200421587 Change-Id: I0ecfa8a651b8d5b743d11aab80d7a4cd71be8b1a Signed-off-by: Debarshi Dutta Reviewed-on: https://git-master.nvidia.com/r/1804509 Reviewed-by: svc-misra-checker Reviewed-by: Konsta Holtta GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/os_fence_android_syncpt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/os_fence_android_syncpt.c b/drivers/gpu/nvgpu/os/linux/os_fence_android_syncpt.c index dc340f1a..f15d0729 100644 --- a/drivers/gpu/nvgpu/os/linux/os_fence_android_syncpt.c +++ b/drivers/gpu/nvgpu/os/linux/os_fence_android_syncpt.c @@ -14,6 +14,7 @@ * along with this program. If not, see . */ +#include #include #include @@ -97,9 +98,9 @@ int nvgpu_os_fence_syncpt_create( struct sync_fence *fence = nvgpu_nvhost_sync_create_fence( nvhost_dev, id, thresh, "fence"); - if (!fence) { + if (IS_ERR(fence)) { nvgpu_err(c->g, "error constructing fence %s", "fence"); - return -ENOMEM; + return PTR_ERR(fence); } nvgpu_os_fence_init(fence_out, c->g, &syncpt_ops, fence); @@ -112,8 +113,9 @@ int nvgpu_os_fence_syncpt_fdget(struct nvgpu_os_fence *fence_out, { struct sync_fence *fence = nvgpu_nvhost_sync_fdget(fd); - if (!fence) + if (fence == NULL) { return -ENOMEM; + } nvgpu_os_fence_init(fence_out, c->g, &syncpt_ops, fence); -- cgit v1.2.2