-
Notifications
You must be signed in to change notification settings - Fork 227
src/update_handler: fix memory leak on G_IO_ERROR_NO_SPACE in clear_slot() #1706
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
How did you find this leak? :) |
Codecov ReportAttention: Patch coverage is
❌ Your patch status has failed because the patch coverage (66.66%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #1706 +/- ##
=======================================
Coverage 84.48% 84.48%
=======================================
Files 76 76
Lines 22286 22288 +2
=======================================
+ Hits 18828 18830 +2
Misses 3458 3458
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
At least for eMMCs, this doesn't guarantee reading back zeroes per reading of the code and checking the eMMC v5.1 spec. We want it to translate to a TRIM command, not a DISCARD, so we would need to do BLKZEROOUT instead. See for more information: barebox/barebox@91a11c7 |
See also #1120 for some discussion regarding discard and zeroing. |
I found it while analysing error-handling paths in the block device clearing logic. Specifically, I noticed that when g_error_matches() returns FALSE, the GError (ierror) isn't cleared or propagated in all cases — which could lead to a memory leak if left unhandled. Glad to help clean it up! :) |
Thanks for explaining that, I take a look of it |
Thanks for reference, I will have a look |
…lot() Signed-off-by: Jialu Zhou <jialu.zhou@viperinnovations.com> Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Force-pushed to align the commit title with our conventions. |
Summary
This PR improves the robustness of clear_slot() by addressing a potential memory leak when G_IO_ERROR_NO_SPACE occurs
Changes
Question
Using
ioctl(fd, BLKDISCARD)
to discard blocks rather than zero-write may be more efficient for flash-based block devices?