gpu: nvgpu: free pmu variables allocated in early_init on error in rtos_init

On error in pmu_rtos_init, pmu state was freed partly. That lead to
invalid access on subsequent nvgpu poweron. Free all pmu state in
such case.

Bug 200575409

Change-Id: I11166b55dbe00a225e811425d21500c3143a354c
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2503577
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Divya Singhatwaria <dsinghatwari@nvidia.com>
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Sagar Kamble
2021-03-23 09:33:04 +05:30
committed by mobile promotions
parent 4d02580df0
commit ecfd675d9b
3 changed files with 14 additions and 3 deletions

View File

@@ -150,6 +150,9 @@ void nvgpu_pmu_remove_support(struct gk20a *g, struct nvgpu_pmu *pmu)
}
#endif
nvgpu_mutex_destroy(&pmu->isr_mutex);
if (g->ops.pmu.ecc_free != NULL) {
g->ops.pmu.ecc_free(g);
}
nvgpu_kfree(g, g->pmu);
g->pmu = NULL;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -208,7 +208,7 @@ static int pmu_sw_setup(struct gk20a *g, struct nvgpu_pmu *pmu )
pmu->sw_ready = true;
exit:
if (err != 0) {
remove_pmu_support(pmu);
nvgpu_pmu_remove_support(g, pmu);
}
return err;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020, 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
* copy of this software and associated documentation files (the "Software"),
@@ -360,14 +360,21 @@ int test_pmu_early_init(struct unit_module *m,
unit_return_fail(m, "support_ls_pmu failed\n");
}
err = g->ops.pmu.ecc_init(g);
nvgpu_pmu_remove_support(g, g->pmu);
if (err != 0) {
unit_return_fail(m, "pmu ecc init failed\n");
}
/*
* case 7: Adding branch coverage
* By setting g->ops.pmu.is_pmu_supported
* to true
*/
g->support_ls_pmu = true;
g->ecc.initialized = false;
g->ops.pmu.is_pmu_supported = stub_gv11b_is_pmu_supported;
err = nvgpu_pmu_early_init(g);
@@ -379,6 +386,7 @@ int test_pmu_early_init(struct unit_module *m,
*/
g->ops.pmu.ecc_init = NULL;
g->ops.pmu.ecc_free = NULL;
err = nvgpu_pmu_early_init(g);
nvgpu_pmu_remove_support(g, g->pmu);