Page MenuHomeFreeBSD

procstat: CID 1593951: Resource leak
ClosedPublic

Authored by dab on Sat, Feb 21, 10:50 PM.
Tags
None
Referenced Files
F146497800: D55422.diff
Tue, Mar 3, 4:05 AM
F146439233: D55422.id172398.diff
Mon, Mar 2, 5:06 PM
Unknown Object (File)
Sun, Mar 1, 7:44 AM
Unknown Object (File)
Sun, Mar 1, 1:51 AM
Unknown Object (File)
Sat, Feb 28, 5:33 PM
Unknown Object (File)
Thu, Feb 26, 3:19 PM
Unknown Object (File)
Thu, Feb 26, 2:21 AM
Unknown Object (File)
Sun, Feb 22, 5:36 PM
Subscribers

Details

Summary

A trivial resource leak fix; free the allocated memory before return.

Test Plan

Code inspection, run command.

I built a simple program that waits for a signal on a kqueue, then ran that. The standard procstat displays:

fbsd-dev% Waiting for SIGTERM...
procstat -a kqueue
    PID       KQFD   FILTER      IDENT      FLAGS     FFLAGS       DATA      UDATA     STATUS
  84352          3   SIGNAL         15          C          -          0        0x0          -

The revised procstat displays:

fbsd-dev% sudo LD_LIBRARY_PATH=/usr/obj/usr/home/dab/git/freebsd/src/arm64.aarch64/lib/libutil /usr/obj/usr/home/dab/git/freebsd/src/arm64.aarch64/usr.bin/procstat/procstat -a kqueue
    PID       KQFD   FILTER      IDENT      FLAGS     FFLAGS       DATA      UDATA     STATUS
  84352          3   SIGNAL         15          C          -          0        0x0          -
fbsd-dev%

As expected, the two displays are identical. This doesn't prove that the leak is gone, but it does prove that the revised command still operates correctly. I think it can clearly be seen from inspection of the change that the leak has been remedied.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable