From 75c9a2eb9477b8d85d11874abfee534d2207011e Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Thu, 5 May 2022 08:00:44 +0530 Subject: [PATCH] gpu: nvgpu: fix nvgpu_dma_alloc_flags_sys cleanup aligned_size was decremented from g->dma_memory_used in case of failure post dma alloc. However, aligned_size is not initialized at that point. Use size instead. CID 446040 Bug 3512546 Change-Id: Id1e117703a3c24dcb9c0b6f3b808c7e30bf90f0b Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2707486 Reviewed-by: svcacv Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Sachin Nikam GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/linux-dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/linux-dma.c b/drivers/gpu/nvgpu/os/linux/linux-dma.c index e56cdb641..482b751a4 100644 --- a/drivers/gpu/nvgpu/os/linux/linux-dma.c +++ b/drivers/gpu/nvgpu/os/linux/linux-dma.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -332,7 +332,7 @@ fail_free_dma: mem->cpu_va = NULL; mem->priv.sgt = NULL; mem->size = 0; - g->dma_memory_used -= mem->aligned_size; + g->dma_memory_used -= size; print_dma_err: nvgpu_dma_print_err(g, size, "sysmem", "alloc", flags); return err;