Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Dec 2019 15:31:41 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 242727] MII device leaks memory on detach
Message-ID:  <bug-242727-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D242727

            Bug ID: 242727
           Summary: MII device leaks memory on detach
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: ghuckriede@blackberry.com

Created attachment 210065
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D210065&action=
=3Dedit
patch

Overview:
The 'args' and 'ivars' malloc()s do not have associated free()s.  See lines=
 397
and 488 of
https://svnweb.freebsd.org/base/head/sys/dev/mii/mii.c?annotate=3D326255.

Here is a proposed fix for this.=20=20

The 'ivars' leak is simple to fix.  Just adding a free in the miibus_detach=
()
solved the issue.

The 'args' leak is a little more complicated.  This is malloc()ed for each =
phy
on the bus "child".  There is currently no detach function for the child.=20
Added miibus_child_detached() to free the 'args'.=20


Steps to Reproduce:
Attach and detach a module with mii devices.  Observe leaks.
# devinfo -v | grep re0
            re0 pnpinfo vendor=3D0x10ec device=3D0x8168 subvendor=3D0x10ec
subdevice=3D0x0123 class=3D0x020000 at slot=3D0 function=3D0 dbsf=3Dpci0:3:=
0:0
handle=3D\_SB_.PCI0.RP02.PXSX
#=20
# devctl detach pci0:3:0:0
#
# vmstat -m | grep devbuf
       devbuf 34770 70136K       -    35686=20
16,32,64,128,256,512,1024,2048,4096,8192,65536
# devctl attach pci0:3:0:0=20
# vmstat -m | grep devbuf
       devbuf 35307 70188K       -    36223=20
16,32,64,128,256,512,1024,2048,4096,8192,65536
# devctl detach pci0:3:0:0
# vmstat -m | grep devbuf
       devbuf 34779 70122K       -    36223=20
16,32,64,128,256,512,1024,2048,4096,8192,65536
#=20


Actual Results:=20
're' LEAKED 9 times of type 'devbuf' (M_DEVBUF).  2 of these leaks are from=
 the
'mii' device.


Expected Results:
Not to leak (or in the 're' case leak less).


Build Date & Hardware:
HEADr355854 on amd64 target with any hardware with mii device(s)

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-242727-227>