I have been debugging some Cellular Init failures and noticed that no cleanup code is executed if Cellular Init fails.
I checked the common implementation and documentation to make sure if user is responsible for calling cleanup themselves but it is not explicitly laid out.
I wouldn’t have thought to call cleanup on failed init calls on a library as well. Not a common practice.
In Cellular Init function, _Cellular_LibInit cleans up the resource allocated when there is error in the function.
Resource allocated by _Cellular_LibInit should also be cleaned up when module port functions return error, including Cellular_ModuleInit, Cellular_ModuleEnableUE and Cellular_ModuleEnableUE.
Thank you for pointing out this problem.
We will create a PR to fix this problem and update in this thread again.