From 9fda4bc276f1702fb8206d4679d44fd7717bf1f0 Mon Sep 17 00:00:00 2001 From: Philip Elcan Date: Thu, 4 Oct 2018 13:10:28 -0400 Subject: [PATCH] gpu: nvgpu: fix malloc return check in POSIX kmem This fixes a bug in nvgpu_kmem_cache_create() where the return of malloc() was incorrectly checked. Bug found as a result of JIRA NVGPU-1235 Change-Id: I1c80f2035df980fd1193cf60dfe6132c1f9b693d Signed-off-by: Philip Elcan Reviewed-on: https://git-master.nvidia.com/r/1919442 Reviewed-by: svc-misra-checker Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/posix/kmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/os/posix/kmem.c b/drivers/gpu/nvgpu/os/posix/kmem.c index 5fe0aeb2e..607ed9f66 100644 --- a/drivers/gpu/nvgpu/os/posix/kmem.c +++ b/drivers/gpu/nvgpu/os/posix/kmem.c @@ -41,7 +41,7 @@ struct nvgpu_kmem_cache *nvgpu_kmem_cache_create(struct gk20a *g, size_t size) struct nvgpu_kmem_cache *cache = malloc(sizeof(struct nvgpu_kmem_cache)); - if (cache != NULL) + if (cache == NULL) return NULL; cache->alloc_size = size;