Hi Jan and Amit, yep u r right guys , But the doubt that arises on my mind is that what happens now whn the rmmod is called ? Now taking the senario , that 'l x' has stated , u r module has been registerd, ie(insmod is done) the function XX_open() may or maynot be invoked , since the MOD_INC_COUNT has not been incremented we cannot say for sure that it didnt invoke the XX_Open func, Possiblites are there that the module might have got struck before MOD_INC_COUNT Statement. In the above senario can u guys plz tell me what will happen if i call rmmod, and is it possible to kill the module in above state ,in - 2.6 (preemptable Kernel). Thanks Anand > -----Original Message----- > From: kernelnewbies-bounce@nl.linux.org > [mailto:kernelnewbies-bounce@nl.linux.org]On Behalf Of > aksingh@hss.hns.com > Sent: Thursday, June 10, 2004 3:49 PM > To: Anandraj > Cc: 'Jan Hudec'; 'l x'; kernelnewbies@nl.linux.org > Subject: RE: Help - can not rmmod a module > > > > > > > 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/ > -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/