gpu: nvgpu: free g->bios on sw init failure

nvgpu_bios_sw_init was not freeing g->bios on init failure
(for instance when board does not complete devinit).
As a result, the function was skipping init at the next
nvgpu_finalize_poweron attempt. This was resulting in a
crash later on, when attempting to parse VBIOS data.

Changed nvgpu_bios_sw_init to free g->bios and set it to
NULL, in case init fails.

Bug 2834853

Change-Id: I87bc18b89674141f713c4043a231a437669c9c94
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2291246
Reviewed-by: Automatic_Commit_Validation_User
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: Vinod Gopalakrishnakurup <vinodg@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:
Thomas Fleury
2020-02-06 18:28:13 -05:00
committed by Alex Waterman
parent 740f26cee5
commit 2d7eb09ab4

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2019, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2015-2020, 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"),
@@ -188,20 +188,24 @@ int nvgpu_bios_sw_init(struct gk20a *g)
nvgpu_tu104_bios_sw_init(g, g->bios);
break;
default:
nvgpu_kfree(g, g->bios);
err = 0;
break;
goto clean_bios;
}
if ((g->bios)->init != NULL) {
err = g->bios->init(g);
if (err != 0) {
nvgpu_falcon_sw_free(g, FALCON_ID_FECS);
goto clean_bios;
}
goto done;
}
done:
return err;
clean_bios:
nvgpu_kfree(g, g->bios);
g->bios = NULL;
return err;
}
void nvgpu_bios_sw_deinit(struct gk20a *g, struct nvgpu_bios *bios)