Interface groups are allocated as follows:

        struct ifg_group *
        if_creategroup(const char *groupname)
        {
                struct ifg_group        *ifg;

                if ((ifg = malloc(sizeof(*ifg), M_TEMP, M_NOWAIT)) == NULL)
                        return (NULL);

                ...
        }

Since this allocation per group does not change, we can use the same
size when freeing it in if_delgroup() accordingly.

Tested on sparc64.

Feedback? OK?


Index: sys/net/if.c
===================================================================
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.610
diff -u -p -r1.610 if.c
--- sys/net/if.c        22 Jun 2020 09:45:13 -0000      1.610
+++ sys/net/if.c        30 Jun 2020 02:00:31 -0000
@@ -2774,7 +2774,7 @@ if_delgroup(struct ifnet *ifp, const cha
 #if NPF > 0
                pfi_detach_ifgroup(ifgl->ifgl_group);
 #endif
-               free(ifgl->ifgl_group, M_TEMP, 0);
+               free(ifgl->ifgl_group, M_TEMP, sizeof(*ifgl->ifgl_group));
        }
 
        free(ifgl, M_TEMP, sizeof(*ifgl));

Reply via email to