From bba49e6ee12a17cdff174aabe348424de57ec5f3 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Wed, 8 Mar 2017 15:22:15 +0530 Subject: gpu: nvgpu: check return value of mutex_init in nvgpu_allocator - check return value of nvgpu_mutex_init in nvgpu_allocator - add corresponding nvgpu_mutex_destroy calls Jira NVGPU-13 Change-Id: I1522b53fb4126fdc2b24fda4b86b45987fe3d203 Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1317137 Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: Navneet Kumar --- drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c b/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c index 20209efc..24a76a0b 100644 --- a/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c @@ -116,6 +116,7 @@ void nvgpu_alloc_release_carveout(struct nvgpu_allocator *a, void nvgpu_alloc_destroy(struct nvgpu_allocator *a) { a->ops->fini(a); + nvgpu_mutex_destroy(&a->lock); memset(a, 0, sizeof(*a)); } @@ -126,6 +127,8 @@ int __nvgpu_alloc_common_init(struct nvgpu_allocator *a, const char *name, void *priv, bool dbg, const struct nvgpu_allocator_ops *ops) { + int err; + if (!ops) return -EINVAL; @@ -136,12 +139,14 @@ int __nvgpu_alloc_common_init(struct nvgpu_allocator *a, if (!ops->alloc || !ops->free || !ops->fini) return -EINVAL; + err = nvgpu_mutex_init(&a->lock); + if (err) + return err; + a->ops = ops; a->priv = priv; a->debug = dbg; - nvgpu_mutex_init(&a->lock); - strlcpy(a->name, name, sizeof(a->name)); return 0; -- cgit v1.2.2