gpu: nvgpu: add NULL check in nvgpu_ecc_free

gr_config can be NULL in nvgpu_ecc_free.
This happens when kernel module is unloaded without ever
powering on the GPU.

Check that gr_config is not NULL, before calling
nvgpu_gr_config_get_gpc_count.

Bug 2691108

Change-Id: Ic0ebeb3e1d283464242d8487c2f4a1bb88920f8a
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2186647
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Thomas Fleury
2019-08-29 17:42:35 -04:00
committed by mobile promotions
parent 023912e46f
commit 237c84a879

View File

@@ -215,9 +215,15 @@ void nvgpu_ecc_free(struct gk20a *g)
{ {
struct nvgpu_ecc *ecc = &g->ecc; struct nvgpu_ecc *ecc = &g->ecc;
struct nvgpu_gr_config *gr_config = nvgpu_gr_get_config_ptr(g); struct nvgpu_gr_config *gr_config = nvgpu_gr_get_config_ptr(g);
u32 gpc_count = nvgpu_gr_config_get_gpc_count(gr_config); u32 gpc_count;
u32 i; u32 i;
if (gr_config == NULL) {
return;
}
gpc_count = nvgpu_gr_config_get_gpc_count(gr_config);
for (i = 0; i < gpc_count; i++) { for (i = 0; i < gpc_count; i++) {
if (ecc->gr.sm_lrf_ecc_single_err_count != NULL) { if (ecc->gr.sm_lrf_ecc_single_err_count != NULL) {
nvgpu_kfree(g, ecc->gr.sm_lrf_ecc_single_err_count[i]); nvgpu_kfree(g, ecc->gr.sm_lrf_ecc_single_err_count[i]);