diff options
author | Debarshi Dutta <ddutta@nvidia.com> | 2018-08-22 06:25:21 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-08-28 09:47:25 -0400 |
commit | 8676b2e65b786497c4a0609f06143e7d1bb1a3c0 (patch) | |
tree | 488f6b2cfda2e58a83b34f3b3316947d4bada51e /drivers/gpu/nvgpu/os | |
parent | 07d3387ceb10cdc4d4413d04b1223cbd5181438b (diff) |
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 <ddutta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1804509
Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com>
Reviewed-by: Konsta Holtta <kholtta@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/os')
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/os_fence_android_syncpt.c | 8 |
1 files 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 @@ | |||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/err.h> | ||
17 | #include <nvgpu/errno.h> | 18 | #include <nvgpu/errno.h> |
18 | 19 | ||
19 | #include <nvgpu/types.h> | 20 | #include <nvgpu/types.h> |
@@ -97,9 +98,9 @@ int nvgpu_os_fence_syncpt_create( | |||
97 | struct sync_fence *fence = nvgpu_nvhost_sync_create_fence( | 98 | struct sync_fence *fence = nvgpu_nvhost_sync_create_fence( |
98 | nvhost_dev, id, thresh, "fence"); | 99 | nvhost_dev, id, thresh, "fence"); |
99 | 100 | ||
100 | if (!fence) { | 101 | if (IS_ERR(fence)) { |
101 | nvgpu_err(c->g, "error constructing fence %s", "fence"); | 102 | nvgpu_err(c->g, "error constructing fence %s", "fence"); |
102 | return -ENOMEM; | 103 | return PTR_ERR(fence); |
103 | } | 104 | } |
104 | 105 | ||
105 | nvgpu_os_fence_init(fence_out, c->g, &syncpt_ops, fence); | 106 | 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, | |||
112 | { | 113 | { |
113 | struct sync_fence *fence = nvgpu_nvhost_sync_fdget(fd); | 114 | struct sync_fence *fence = nvgpu_nvhost_sync_fdget(fd); |
114 | 115 | ||
115 | if (!fence) | 116 | if (fence == NULL) { |
116 | return -ENOMEM; | 117 | return -ENOMEM; |
118 | } | ||
117 | 119 | ||
118 | nvgpu_os_fence_init(fence_out, c->g, &syncpt_ops, fence); | 120 | nvgpu_os_fence_init(fence_out, c->g, &syncpt_ops, fence); |
119 | 121 | ||