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)
Tue, Jul 9, 11:43 PM
Unknown Object (File)
Mon, Jul 1, 1:48 PM
Unknown Object (File)
Apr 30 2024, 1:33 PM
Unknown Object (File)
Apr 30 2024, 1:33 PM
Unknown Object (File)
Apr 30 2024, 1:33 PM
Unknown Object (File)
Apr 30 2024, 1:33 PM
Unknown Object (File)
Apr 30 2024, 7:14 AM
Unknown Object (File)
Apr 26 2024, 3:59 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.