Adafruit_ZeroDMA
Adafruit_ZeroDMA copied to clipboard
Adafruit_ZeroDMA::addDescriptor returning static pointer
From https://github.com/adafruit/Adafruit_ZeroDMA/blob/64dce3e63f7589c6d365dbd75b1b420e69bcce6e/Adafruit_ZeroDMA.cpp#L450
You'll want to keep the pointer for later if you need to modify or free the descriptor.
Looking at the implementation, &_descriptor[channel] is being return if addDescriptor is first called on a new Adafruit_ZeroDMA object. _descriptor is allocated statically in the .hsram section.
If I understood the code correctly, freeing the pointer returned from the first call to addDescriptor is freeing a non heap ptr which will cause an error.
The description should be updated so the first descriptor will be treated differently thus not freed by accident.
Or with more changes, caller of addDescriptor should be able to treat descriptors returned from it in the same way.