LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 07-29-2012, 11:12 PM   #1
SIG_SEGV
Member
 
Registered: Jul 2012
Location: Banglore, INDIA
Distribution: Fedora-Core
Posts: 70

Rep: Reputation: 11
"insmod inserted the LKM into the kernel, But rmmod not removing it back"


I am learning Kernel module programming and so have tried for the simple example.
#include <asm/current.h>
#include <linux/sched.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static void pro_init(void)
{
printk (KERN_ALERT "The process is \"%s\" (pid %i)\n",current->comm, current->pid);
}

static void pro_exit(void)
{
printk (KERN_ALERT "The process has exited\n");
}
module_init(pro_init);
module_exit(pro_exit);

The program worked with no problems. But when i removed off the last 2 lines of kernel_macros, recompiled the module and inserted it back to the kernel, The module was successfully inserted. lsmod shows the inserted module. Now when i try to unlink the module by 'rmmod' it says 'device/resource busy'.

How come the kernel now is in need of clean_up (module_exit) macro where it didn't bother of 'module_init' macro when i used insmod to insert the module....???
 
Old 07-31-2012, 03:59 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,404

Rep: Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337
sudo rmmod -f ?
 
Old 07-31-2012, 04:47 AM   #3
SIG_SEGV
Member
 
Registered: Jul 2012
Location: Banglore, INDIA
Distribution: Fedora-Core
Posts: 70

Original Poster
Rep: Reputation: 11
No, I have actually found the solution for the problem. It was 'my program lacked with a cleanup module (module_exit(--)) in the end. But my question is.......

"How come the kernel now is in need of clean_up (module_exit) macro. Because it didn't bother of 'module_init' macro when i used insmod to insert the module without (module_init)....???"
 
Old 07-31-2012, 09:17 AM   #4
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,404

Rep: Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337Reputation: 2337
It should be obvious - rescue allocated resources, etc.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
insmod hello.ko: -1 Invalid module format ("vermagic" and "uname -r" are the same!) courteous Linux - Kernel 8 02-16-2011 11:09 PM
insmod: getting "KIlled" message while inserting kernel module linuxkiddie Linux - Newbie 3 05-18-2010 10:46 AM
rmmod results in "bad file descriptor" wpbgent Linux - Newbie 1 07-29-2008 09:57 AM
K3b: - Howto re-dock "Directories" and "Contents" windows back into the main window? hagies Linux - Software 4 04-26-2006 08:38 AM
Compiling a kernel module results in "insmod" version mvega Linux - General 2 07-30-2003 09:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 12:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration