DspFpgaGpio.cpp: i f (Bank > mnNumBanks) return -1

Added by John Cumming over 6 years ago


In tcDspFpgaGpio::ConfigurePin(unsigned int Bank, unsigned int Offset, etc.) and a few other fctns in DspFpgaGpio.cpp, there's a test for a valid value for the Bank arg and for the Offset arg, like:

    if (Bank > mnNumBanks) {
        return -1;
    if (Offset > mnIOPerBank) {
        return -1;

For example, if mnNumBanks is 2 and the requested Bank is 2 (which is the 3rd bank, right?), the fctn accesses the memory for the 3rd bank, even though there are only 2.

Certainly this doesn't matter except for the border condition, when the Bank number passed to the fctn is 1 more than the maximum valid value. It'll probably never happen. :-)

There are 6 places in this file that test Bank and prob should have an equals sign, like:
if (Bank >= mnNumBanks)
return -1;
And 4 places where Offset is tested and need an equal sign, like:
if (Offset >= mnIOPerBank)
return -1;


Replies (1)

RE: DspFpgaGpio.cpp: i f (Bank > mnNumBanks) return -1 - Added by Michael Williamson over 6 years ago

Hi John,

You are correct. We've pulled in this fix and it will get published in the next release for the MityDSP-L138 BSP.

Thanks for the bug report.


    Add picture from clipboard (Maximum size: 500 MB)