[Bug 242712] Networking device detach leaks memory

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed Dec 18 18:50:16 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242712

            Bug ID: 242712
           Summary: Networking device detach leaks memory
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: kern
          Assignee: bugs at FreeBSD.org
          Reporter: ghuckriede at blackberry.com

Created attachment 210040
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=210040&action=edit
before and after test results

A free() appears to have been removed by mistake.

line 1544 of https://svnweb.freebsd.org/base/head/sys/net/if.c?annotate=334117
was removed by the following submission:        
https://svnweb.freebsd.org/base/head/sys/net/if.c?revision=334118&view=markup

This introduced a memory leak when calling if_delgroups(), as the malloc is
still present in if_addgroup() on line 1458 of
https://svnweb.freebsd.org/base/head/sys/net/if.c?annotate=355070

Furthermore the free() is present for if_delgroup() on line 1551 of
https://svnweb.freebsd.org/base/head/sys/net/if.c?annotate=355070

Here is a fix along with a white space change.

svn diff sys/net/if.c
Index: sys/net/if.c
===================================================================
--- sys/net/if.c        (revision 355854)
+++ sys/net/if.c        (working copy)
@@ -1594,9 +1594,10 @@
                free(ifgm, M_TEMP);
                if (ifglfree) {
                        EVENTHANDLER_INVOKE(group_detach_event,
-                                                              
ifgl->ifgl_group);
+                                           ifgl->ifgl_group);
                        free(ifgl->ifgl_group, M_TEMP);
                }
+               free(ifgl, M_TEMP);
                EVENTHANDLER_INVOKE(group_change_event, groupname);

                IFNET_WLOCK();

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


More information about the freebsd-bugs mailing list