Page MenuHomeFreeBSD

Fix a memory leak in newfs_msdos
AbandonedPublic

Authored by emaste on Feb 20 2017, 4:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jan 29, 11:13 AM
Unknown Object (File)
Sat, Jan 17, 12:58 AM
Unknown Object (File)
Jan 15 2026, 6:34 PM
Unknown Object (File)
Jan 12 2026, 12:24 PM
Unknown Object (File)
Jan 10 2026, 3:15 PM
Unknown Object (File)
Dec 28 2025, 11:44 PM
Unknown Object (File)
Nov 17 2025, 5:09 PM
Unknown Object (File)
Nov 17 2025, 4:02 PM
Subscribers
None

Details

Summary

When the input file is not a path, memory is allocated and reassigned to the variable 'fname' and never freed.

Track this use case with the new variable 'local_fname' and free the memory after its use. The fname qualify 'const' is removed because the variable really isn't const and scan-build complains of use of const with free. The variable 'ret' introduced to hold the return status of mkfs_msdos() so fname could be freed.

Test Plan

Run clang's static analyzer, scan-build, before to reproduce the problem; run scan-build after to show problem is resolved.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

trix_juniper.net retitled this revision from to Fix a memory leak in newfs_msdos.
trix_juniper.net updated this object.
trix_juniper.net edited the test plan for this revision. (Show Details)
trix_juniper.net added reviewers: stevek, imp.
trix_juniper.net set the repository for this revision to rS FreeBSD src repository - subversion.
emaste abandoned this revision.
emaste added a reviewer: trix_juniper.net.

Addressed by 2780a26b6a306