Re: Help - can not rmmod a module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 10, 2004 at 15:40:51 +0530, Anandraj wrote:
> 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 ,

delete_module will first check, if the module's use count is zero. If
it's not, it will return -EBUSY and won't bother calling clenup_module,
nor actualy removing anything! It obviously follows, that
MOD_DEC_USE_COUNT in cleanup_module is pointless and equaly obviously
follows, that MOD_INC_USE_COUNT in init_module efficiently prevents
unloading that module.

Actualy, MOD_INC/DEC_USE_COUNT is an inherent race condition -- the
module use count must be manipulated by code using the module, not the
module itself.

> But IMHO , if u are not freeing the memory that has been allocated before,
> then u r module
> is for sure to crash !!!

No. You are not. The memory will just stay around and take up space.
Another problem is if you fail to remove pointers to your functions --
they now point to void, and jumping there usualy proves fatal.

> Let me know if im wrong ,

Yes, you are ;-).

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux