-
Notifications
You must be signed in to change notification settings - Fork 3k
Add check so that FlashIAP does not allocate memory on flash_init failure #12531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@dustin-crossman, thank you for your changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Astyle issue should be fixed but otherwise code change looks good.
1e01368
to
2f97c2d
Compare
@evedon Fixed up! |
CI started |
Correct, I don't see any undefined behavor specified in this driver, yet. |
Test run: FAILEDSummary: 2 of 7 test jobs failed Failed test jobs:
|
CI restarted |
Test run: FAILEDSummary: 1 of 7 test jobs failed Failed test jobs:
|
Client restarted |
Summary of changes
Adds a check to ensure FlashIAP does not allocate memory (with new[]) if a targets flash_init() call fails.
This fixes: #12439
Note: I did not add a similar check to the deinit to prevent calling delete[] on _page_buf if flash_free fails. There are a couple reasons for this:
Impact of changes
Migration actions required
Documentation
None
Pull request type
Test results
This can't really be tested programmatically since there is no way to modify a targets mbed_hal implementation during a test but I ran the mbed_hal-flash and mbed_drivers-flashiap tests under two different conditions.
Condition 1: pr/flashiap_fix branch with no changes:
mbed_hal-flash passes
mbed_drivers-flashiap passes
Condition 2: pr/flashiap_fix branch with flash_init() modified to always return failure:
mbed_hal-flash fails (as expected)
mbed_drivers-flashiap fails (as expected) but with no OOM error.
Reviewers