Cleanup_module is called only if module is not in use(MOD_IN_USE evaluates to false), so as Jan said if a module cannot be unloaded cleanup_module is not called at all. MOD_INC_USE_COUNT is not/should not be done in init_module,uld be done in someother function, like an open() and MOD_DEC_USE_COUNT should not be done in cleanup_module it shld be done in some other module like close(); Amit Anandraj <arm@tataelxsi.co.in>@nl.linux.org on 06/10/2004 03:40:51 PM Sent by: kernelnewbies-bounce@nl.linux.org To: "'Jan Hudec'" <bulb@ucw.cz> cc: "'l x'" <whereisit28@yahoo.com>, kernelnewbies@nl.linux.org Subject: RE: Help - can not rmmod a module Hi Jan, > The cleanup_module function has no way whatsoever preventing > the unload. > If a module can't be unloaded, cleanup_module is not called at all. So > this is not the problem. AFAIK when u call rmmod, the function that gets called is delete_module which inturn calls cleanup_module() The general practice what ppl follow in cleanup_module is kfree() all the memory that has been allocated before(using kmalloc), then call MOD_DEC_USE_COUNT , to decrease the count , But IMHO , if u are not freeing the memory that has been allocated before, then u r module is for sure to crash !!! Let me know if im wrong , Rgds Anand > -----Original Message----- > From: Jan Hudec [mailto:bulb@vagabond.light.src]On Behalf Of Jan Hudec > Sent: Thursday, June 10, 2004 3:22 PM > To: Anandraj > Cc: 'l x'; kernelnewbies@nl.linux.org > Subject: Re: Help - can not rmmod a module > > > On Thu, Jun 10, 2004 at 09:53:35 +0530, Anandraj wrote: > > Hi > > check wheather u r freeing the memory u have allocated in > init_module or > > some were else! > > The memory allocated should be freeed atleast in the > cleanup_module() > > The cleanup_module function has no way whatsoever preventing > the unload. > If a module can't be unloaded, cleanup_module is not called at all. So > this is not the problem. > > -------------------------------------------------------------- > ----------------- > Jan 'Bulb' > Hudec <bulb@ucw.cz> > -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/