2010-02-04 04:40:52     tty_unregister_driver versus tty_register_driver unbalanced

Document created by Aaronwu Employee on Aug 20, 2013
Version 1Show Document
  • View in full screen mode

2010-02-04 04:40:52     tty_unregister_driver versus tty_register_driver unbalanced

Filip Van Rillaer (BELGIUM)

Message: 85606   

 

Hello,

 

The function tty_register_driver (tty_io.c) is calling proc_tty_register_driver.

 

The function tty_unregister_driver is however not calling proc_tty_unregister_driver.  This way part ot the tty-driver is not cleaned up when it is unloaded.  So I think that following code should be added to the function tty_unregister_driver (at least in my setup it solved my problems) :

void *p;

p =  driver->ttys;

proc_tty_unregister_driver(driver);

kfree(p);

 

Please comment.

 

Best regards,

 

Filip

TranslateQuoteReplyEditDelete

 

 

2010-02-04 11:22:01     Re: tty_unregister_driver versus tty_register_driver unbalanced

Mike Frysinger (UNITED STATES)

Message: 85611   

 

it is called implicitly by the kref code a little bit down:

void tty_driver_kref_put(struct tty_driver *driver)

{

    kref_put(&driver->kref, destruct_tty_driver);

}

static void destruct_tty_driver(struct kref *kref)

{

...

        proc_tty_unregister_driver(driver);

...

 

just because you unregister something doesnt mean other processes/kernel threads dont still have a handle to the tty device.  so once you unregister and everything else has released the resources, then the proc and related resources get released.

QuoteReplyEditDelete

 

 

2010-02-05 10:02:05     Re: tty_unregister_driver versus tty_register_driver unbalanced

Filip Van Rillaer (BELGIUM)

Message: 85706   

 

Thank you Mike.

 

I agree with your comment but for some reason the function you mention is not called when I kill all threads and unload all modules I am using.

Though I get following messages when unloading my module followed by loading it again:

 

kobject: 'onemodem0' (025dd268): kobject_add_internal: parent: 'tty', set: 'devices'

 

kobject: 'onemodem0' (025dd268): kobject_cleanup

kobject: 'onemodem0' (025dd268): calling ktype release

kobject: 'onemodem0': free name

kobject: 'holders' (028e85a0): kobject_cleanup

kobject: 'holders' (028e85a0): auto cleanup kobject_del

kobject: 'holders' (028e85a0): calling ktype release

kobject: (028e85a0): dynamic_kobj_release

kobject: 'holders': free name

kobject: 'modtlmdmcl1' (02f1ea24): kobject_cleanup

kobject: 'modtlmdmcl1' (02f1ea24): does not have a release() function, it is broken and must be fixed.

kobject: 'modtlmdmcl1' (02f1ea24): auto cleanup kobject_del

kobject: 'modtlmdmcl1': free name

kobject: 'modtlmdmcl1' (0129ea24): kobject_add_internal: parent: 'module', set: 'module'

kobject: 'holders' (00476c60): kobject_add_internal: parent: 'modtlmdmcl1', set: '<NULL>'

------------[ cut here ]------------

WARNING: at fs/proc/generic.c:590 _proc_register+0x96/0x13c()

proc_dir_entry 'driver/onemodem' already registered

 

 

Is that due to something missing in my code or not?

 

Best regards,

 

Filip

TranslateQuoteReplyEditDelete

 

 

2010-02-08 03:34:44     Re: tty_unregister_driver versus tty_register_driver unbalanced

Filip Van Rillaer (BELGIUM)

Message: 85757   

 

Hello Mike,

 

Calling put_tty_driver solved my problem.

 

The message:

<<does not have a release() function, it is broken and must be fixed>>

seems to be not directly related to my problem, but in general when unloading any module.

 

Thanks for t he support.

 

Best regards,

 

Filip

TranslateQuoteReplyEditDelete

 

 

2010-02-08 03:40:48     Re: tty_unregister_driver versus tty_register_driver unbalanced

Mike Frysinger (UNITED STATES)

Message: 85758   

 

i'm not terribly familiar with the tty core, but looking at other random drivers, it seems like calling put_tty_driver() after tty_unregister_driver() is the right thing to do

Attachments

    Outcomes