Page MenuHomeFreeBSD

Fix double free in case of mount error.

Authored by fsu on Feb 27 2019, 11:37 AM.



It was found, that if cg descriptors bread() will return error, the fs->e2fs_gd and fs->e2fs_contigdirs sb fields will be freed twice.
Immediately after bread() call and at the bottom of the ext2_mountfs() function.
It is not possible to free these in-memory superblocks fields immediately after bread(), because the compute_sb_data() function is used in case of ro/rw remounting.
So, choose the second place and remove free() calls immediately after bread().

Test Plan

Tested manually with problem fs image.
And some ro/rw remount manual tests had place.

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

fsu created this revision.Feb 27 2019, 11:37 AM
pfg accepted this revision.Feb 27 2019, 2:34 PM
pfg added inline comments.
474 ↗(On Diff #54470)

Remove "The" from here: we are talking about two things so we cannot use a singular.

This revision is now accepted and ready to land.Feb 27 2019, 2:34 PM
This revision was automatically updated to reflect the committed changes.