From owner-freebsd-bugs@freebsd.org Thu Dec 19 15:31:42 2019 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 37C821E3469 for ; Thu, 19 Dec 2019 15:31:42 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 47dwpQ0pGNz3JlV for ; Thu, 19 Dec 2019 15:31:42 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 1B8401E3468; Thu, 19 Dec 2019 15:31:42 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1B48E1E3467 for ; Thu, 19 Dec 2019 15:31:42 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47dwpP73Qqz3JlR for ; Thu, 19 Dec 2019 15:31:41 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D45A718A77 for ; Thu, 19 Dec 2019 15:31:41 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id xBJFVf8c079390 for ; Thu, 19 Dec 2019 15:31:41 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id xBJFVf2l079389 for bugs@FreeBSD.org; Thu, 19 Dec 2019 15:31:41 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 242727] MII device leaks memory on detach Date: Thu, 19 Dec 2019 15:31:41 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: ghuckriede@blackberry.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Dec 2019 15:31:42 -0000 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.=