Page MenuHomeFreeBSD

Fix a memory leak introduced in r328426.
ClosedPublic

Authored by markj on Feb 15 2018, 9:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 28, 8:48 PM
Unknown Object (File)
Nov 3 2024, 2:39 AM
Unknown Object (File)
Nov 1 2024, 10:46 PM
Unknown Object (File)
Oct 31 2024, 2:39 AM
Unknown Object (File)
Oct 5 2024, 5:01 AM
Unknown Object (File)
Oct 1 2024, 7:42 PM
Unknown Object (File)
Sep 28 2024, 4:16 AM
Unknown Object (File)
Sep 27 2024, 10:19 PM
Subscribers

Details

Summary

ffs_sbget() may return a superblock buffer even if it fails. Moreover,
readfunc returns a dynamically allocated buffer, when we call it on
backup superblocks, we need to free the previously allocated buffer.
Also fix what I believe is a free() of an uninitialized pointer if the
ffs_sbget() call in ffs_mountfs() fails before "fs" is set.

Test Plan

pho reported finding the leak while testing gmirror, tracked it down
to the aforementioned revision, and tested an earlier version of this
diff.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj added reviewers: mckusick, kib.
markj added a subscriber: pho.
kib added inline comments.
lib/libufs/sblock.c
153 ↗(On Diff #39359)

if () is redundant.

sys/ufs/ffs/ffs_subr.c
217 ↗(On Diff #39359)

Most likely, this if () is redundant.

sys/ufs/ffs/ffs_vfsops.c
1078 ↗(On Diff #39359)

I think if() is redundant.

This revision is now accepted and ready to land.Feb 15 2018, 10:15 PM
  • Remove unneeded if statements.
This revision now requires review to proceed.Feb 15 2018, 10:49 PM

I ran tests on D14390.39361 for 7 hours. LGTM.

This revision was not accepted when it landed; it landed in state Needs Review.Feb 16 2018, 3:41 PM
This revision was automatically updated to reflect the committed changes.