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 <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2707486
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Sagar Kamble
2022-05-05 08:00:44 +05:30
committed by mobile promotions
parent c32c4025a4
commit 75c9a2eb94

View File

@@ -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 * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -332,7 +332,7 @@ fail_free_dma:
mem->cpu_va = NULL; mem->cpu_va = NULL;
mem->priv.sgt = NULL; mem->priv.sgt = NULL;
mem->size = 0; mem->size = 0;
g->dma_memory_used -= mem->aligned_size; g->dma_memory_used -= size;
print_dma_err: print_dma_err:
nvgpu_dma_print_err(g, size, "sysmem", "alloc", flags); nvgpu_dma_print_err(g, size, "sysmem", "alloc", flags);
return err; return err;