Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 12383

Kernel modules __init macro in C

$
0
0

I want to create a loadable kernel module for Linux. This is the code

#include <linux/module.h>
#include <linux/init.h>

static int __init mymodule_init(void)
{
 printk ("My module worked!\n");
        return 0;
}

static void __exit mymodule_exit(void)
{
 printk ("Unloading my module.\n");
        return;
}

module_init(mymodule_init);
module_exit(mymodule_exit);

MODULE_LICENSE("GPL");

Pay now attention to the __init macro. As the doc says:

The __init macro indicates to compiler that that associated function is only used during initialization. Compiler places all code marked with __init into a special memory section that is freed after initialization

I'm trying to understand why the initialization method can end up leaking memory. Is it due to the FIFO disposition of function calls in the stack ?


Viewing all articles
Browse latest Browse all 12383

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>