gpu: nvgpu: add NULL checks before freeing ZBC and ZCULL

Disabling NVGPU_SUPPORT_MIG in suspend path leads to inconsistencies.
During driver removal without the flag set, the driver still tries
to free structures that might not have been allocated in the first place.
e.g. nvgpu_gr_zbc_deinit, nvgpu_gr_zcull_deinit.

Added NULL checks for ZBC and ZCULL structures before freeing them as a
solution.

Jira NVGPU-6832

Change-Id: I8a0c64ca982d11fee55542abd3c5bce5a51b4007
Signed-off-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2535101
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Lakshmanan M <lm@nvidia.com>
Reviewed-by: Dinesh T <dt@nvidia.com>
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Debarshi Dutta
2021-05-26 16:31:39 +05:30
committed by mobile promotions
parent 9f43914933
commit 11d27743f8
2 changed files with 9 additions and 1 deletions

View File

@@ -602,6 +602,10 @@ alloc_err:
/* deallocate the memory for the struct */ /* deallocate the memory for the struct */
void nvgpu_gr_zbc_deinit(struct gk20a *g, struct nvgpu_gr_zbc *zbc) void nvgpu_gr_zbc_deinit(struct gk20a *g, struct nvgpu_gr_zbc *zbc)
{ {
if (zbc == NULL) {
return;
}
nvgpu_kfree(g, zbc->zbc_col_tbl); nvgpu_kfree(g, zbc->zbc_col_tbl);
nvgpu_kfree(g, zbc->zbc_dep_tbl); nvgpu_kfree(g, zbc->zbc_dep_tbl);
nvgpu_kfree(g, zbc->zbc_s_tbl); nvgpu_kfree(g, zbc->zbc_s_tbl);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -72,6 +72,10 @@ exit:
void nvgpu_gr_zcull_deinit(struct gk20a *g, struct nvgpu_gr_zcull *gr_zcull) void nvgpu_gr_zcull_deinit(struct gk20a *g, struct nvgpu_gr_zcull *gr_zcull)
{ {
if (gr_zcull == NULL) {
return;
}
nvgpu_kfree(g, gr_zcull); nvgpu_kfree(g, gr_zcull);
} }