Page MenuHomeFreeBSD

Fix leaks and test for getpagesize() returning == -1
ClosedPublic

Authored by ngie on Apr 19 2016, 9:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 14 2024, 10:07 PM
Unknown Object (File)
Sep 8 2024, 7:02 AM
Unknown Object (File)
Sep 7 2024, 4:41 PM
Unknown Object (File)
Aug 6 2024, 5:53 PM
Unknown Object (File)
Jul 7 2024, 4:04 AM
Unknown Object (File)
Jun 12 2024, 2:03 PM
Unknown Object (File)
May 8 2024, 3:58 PM
Unknown Object (File)
May 8 2024, 3:11 PM

Details

Reviewers
cem
Summary

Fix leaks and test for getpagesize() returning == -1

  • close file descriptors after use.
  • Always munmap memory regions after mmap'ing them.
  • Make sure getpagesize() returns a value greater than 0 and use a cached value instead of always calling getpagesize(3).

MFC after: 2 weeks
Reported by: Coverity
CID: 1331374-1331377, 1331653-1331662
Sponsored by: EMC / Isilon Storage Division

Test Plan

sudo kyua test -k /usr/tests/sys/vm/Kyuafile

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 3331
Build 3366: arc lint + arc unit

Event Timeline

ngie retitled this revision from to Fix leaks and test for getpagesize() returning == -1.
ngie updated this object.
ngie edited the test plan for this revision. (Show Details)
ngie added subscribers: cem, jhb, markj.
cem added a reviewer: cem.
cem added inline comments.
tests/sys/vm/mmap_test.c
257โ€“258

What about munmaping p1, p2, p3?

This revision is now accepted and ready to land.Apr 19 2016, 10:13 PM
ngie added inline comments.
tests/sys/vm/mmap_test.c
257โ€“258

Good catch -- fixed :).

Ok I guess?

I've yet to see the ATF stuff ever run more than one test in a process. It seems to always want to start a new process to run each test, so doing the cleanups here is just slowing things down (which seems somewhat ironic given that you are micro-optimizing getpagesize() which will never fail).

In D6011#128048, @jhb wrote:

Ok I guess?

I've yet to see the ATF stuff ever run more than one test in a process. It seems to always want to start a new process to run each test, so doing the cleanups here is just slowing things down (which seems somewhat ironic given that you are micro-optimizing getpagesize() which will never fail).

True, there is a separate process for each ATF test. But I think the cleanup is worth it just to make Coverity shut up. It helps to find the real Coverity bugs, like the buffer overflow that cem fixed yesterday.