FreeBSD Bugzilla – Attachment 227138 Details for
Bug 256714
net: Multiple memory leaks when detaching a device
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
proposed patch
leaks.diff (text/plain), 2.12 KB, created by
jcaplan
on 2021-08-12 18:44:01 UTC
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
jcaplan
Created:
2021-08-12 18:44:01 UTC
Size:
2.12 KB
patch
obsolete
>diff --git a/sys/net/pfil.c b/sys/net/pfil.c >index 4968bb8cc4de..66448150308f 100644 >--- a/sys/net/pfil.c >+++ b/sys/net/pfil.c >@@ -251,6 +251,7 @@ pfil_head_unregister(pfil_head_t ph) > link->link_hook->hook_links--; > free(link, M_PFIL); > } >+ free(ph, M_PFIL); > PFIL_UNLOCK(); > } > >diff --git a/sys/netinet6/in6_fib_algo.c b/sys/netinet6/in6_fib_algo.c >index 04d194273168..ae33161e5f24 100644 >--- a/sys/netinet6/in6_fib_algo.c >+++ b/sys/netinet6/in6_fib_algo.c >@@ -156,9 +156,42 @@ static void > lradix6_destroy(void *_data) > { > struct lradix6_data *lr = (struct lradix6_data *)_data; >+ int i, j, k; >+ struct radix6_addr_entry *ae; >+ /* 2 records per addr entry */ >+ size_t max_items = lr->num_items * 2; > > if (lr->rnh != NULL) > rn_detachhead((void **)&lr->rnh); >+ >+ /* rn_detachhead doesn't clean up all the rn_mklist entries properly. >+ * Since we know we're done, we can do a second pass here on the flat >+ * array of nodes to free any pointers when we see them for the first time. >+ */ >+ struct radix_mask **mask_list = malloc(max_items * sizeof(void *), M_RTABLE, 0); >+ memset(mask_list, 0, max_items * sizeof(void *)); >+ int cur_entry = 0; >+ for (i = 0; i < lr->num_items; i++) { >+ ae = (struct radix6_addr_entry *)((char *)lr->radix_mem + >+ (i * LRADIX6_ITEM_SZ)); >+ for (j = 0; j < 2; j++) { >+ if (ae->rn[j].rn_mklist != NULL) { >+ bool found = false; >+ for (k = 0; k < cur_entry; k++) { >+ if (ae->rn[j].rn_mklist == mask_list[k]) { >+ found = true; >+ break; >+ } >+ } >+ if (!found) { >+ free(ae->rn[j].rn_mklist, M_RTABLE); >+ mask_list[cur_entry++] = ae->rn[j].rn_mklist; >+ } >+ } >+ } >+ } >+ free(mask_list, M_RTABLE); >+ > if (lr->mem != NULL) > free(lr->mem, M_RTABLE); > free(lr, M_RTABLE); >diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c >index 1a07fb13b179..63c138a64234 100644 >--- a/sys/netinet6/in6_ifattach.c >+++ b/sys/netinet6/in6_ifattach.c >@@ -525,8 +525,8 @@ in6_ifattach_linklocal(struct ifnet *ifp, struct ifnet *altifp) > /* Reference prefix */ > ia->ia6_ndpr = pr; > pr->ndpr_addrcnt++; >- } else >- nd6_prefix_rele(pr); >+ } >+ nd6_prefix_rele(pr); > > return 0; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 256714
:
225929
|
225968
| 227138