Freeing non heap memory
-
17-06-2021 - |
Domanda
static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
.forwarding = 0,
.hop_limit = IPV6_DEFAULT_HOPLIMIT,
.mtu6 = IPV6_MIN_MTU,
};
static int __net_init addrconf_init_net(struct net *net)
{
struct ipv6_devconf *dflt;
dflt = &ipv6_devconf_dflt;
kfree(dflt);
}
ipv6_devconf_dflt
is a static structure variable. Address of ipv6_devconf_dflt
is assigned to local variable. which is then freed using kfree()
.
Is it allowed to free non-heap memory?
Soluzione
No—it doesn't make sense to free memory outside the heap, because kfree()
only works to free up memory in the context of kmalloc()
ed chunks!
Timeline:
- Committed in January 2008 when the IPv6 devconfs for namespaces came into being.
- Noticed on linux-netdev in August 2008, to no fanfare.
- Pointed out again on the LKML in 2010, with a patch request coming back from the original author, with no patch ever materialised.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow