Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to remove a loadable kernel module

I'm writing a loadable kernel module and trying to test it. After inserting it I was trying to remove it using rmmod xxx command, but I get an error saying module xxx is in use and the module gets stuck and I can't remove it. Any idea how to remove the module without rebooting the entire machine ? (linux Kernel v. 3.5.0)

Note: rmmod -f prints Error: device or resource busy

like image 937
Varda Elentári Avatar asked Jun 22 '13 14:06

Varda Elentári


2 Answers

One possibility is you forget to provide module_exit, so your module doesn't know how to exit.

like image 134
Chen Li Avatar answered Oct 14 '22 10:10

Chen Li


This only happens to me when there is a bug in my driver which is causing the code in the module to panic or crash in some way. In my experience once this happens reboot is the only possible course.

As I said, the kernel usually panics so you should check out dmesg after inserting it or running you application to exercise it. I'm not certain but it might be possible that if the driver doesn't release a mutex this behavior will happen as well.

like image 38
Benjamin Leinweber Avatar answered Oct 14 '22 10:10

Benjamin Leinweber