Fix: hal_iface_init() is not using malloc() anymore when ATCA_NO_HEAP… - #423
Open
fr89k wants to merge 1 commit into
Open
Fix: hal_iface_init() is not using malloc() anymore when ATCA_NO_HEAP…#423fr89k wants to merge 1 commit into
fr89k wants to merge 1 commit into
Conversation
… and ATCA_HAL_CUSTOM are set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ATCA_NO_HEAP does not cover the custom-HAL allocation in hal_iface_init()
Affected versions
d49c7d5)Configuration
Bare-metal target (no heap), built with:
Problem
With
ATCA_NO_HEAPdefined, the library is documented (and annotated) to perform nodynamic memory allocation. However,
hal_iface_init()(lib/hal/atca_hal.c) allocates the custom-HALfunction-pointer struct unconditionally when
ATCA_CUSTOM_IFACEis used(
lib/hal/atca_hal.c:306-308, v3.8.0):Observed behaviour
On a heapless target (
mallocreturns NULL),atcab_init()with acustom-HAL
ATCAIfaceCfgfails withATCA_ALLOC_FAILURE.Expected behaviour
With
ATCA_NO_HEAPdefined, no code path callshal_malloc/hal_free.Suggested fix
When using
ATCA_NO_HEAP, use a staticATCAHAL_tinstance inhal_iface_init().