<div dir="ltr">Still working on this. Here is some dmesg spew:<div><br></div><div><div>[ 514.245846] foobar: module verification failed: signature and/or required key missing - tainting kernel</div><div>[ 514.245937] kobject: 'foobar' (f7f060c8): kobject_add_internal: parent: 'module', set: 'module'</div>
<div>[ 514.245951] kobject: 'holders' (f5ff3d40): kobject_add_internal: parent: 'foobar', set: '<NULL>'</div><div>[ 514.245981] kobject: 'notes' (f2d25f80): kobject_add_internal: parent: 'foobar', set: '<NULL>'</div>
<div>[ 514.245987] kobject: 'foobar' (f7f060c8): kobject_uevent_env</div><div>[ 514.245998] kobject: 'foobar' (f7f060c8): fill_kobj_path: path = '/module/foobar'</div></div><div><br></div><div>So it looks like kernel validation is failing. I have printk's in my init fxn that are never turning up in /var/log/messages, until, weirdly, AFTER I remove the device:</div>
<div><br></div><div><insmod device></div><div><div>Dec 30 09:43:03 localhost kernel: [ 514.245846] foobar: module verification failed: signature and/or required key missing - tainting kernel</div><div>Dec 30 09:43:16 localhost fprintd[1085]: ** Message: No devices in use, exit</div>
</div><div><br></div><div><rmmod device></div><div><div>Dec 30 09:45:53 localhost kernel: [ 514.249323] foobar: got device number 248, minor is 0 <<<<----THIS IS IN init() fxn</div><div>Dec 30 09:45:53 localhost kernel: [ 684.102912] unregister_chrdev(248) called for foobar<7>[ 684.102927] kobject: '(null)' (f7f06220): kobject_cleanup, parent (null)</div>
</div><div><br></div><div><insmod></div><div>insmod: ERROR: could not insert module ./foobar.ko: Device or resource busy<br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Dec 27, 2013 at 9:13 PM, <span dir="ltr"><<a href="mailto:Valdis.Kletnieks@vt.edu" target="_blank">Valdis.Kletnieks@vt.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Fri, 27 Dec 2013 19:33:50 -0800, Eric Fowler said:<br>
<br>
> I suspect I am doing something wrong in the code with<br>
> register/unregister_chrdev(), but I have been over that code a million<br>
> times. It looks fine.<br>
><br>
> Now:<br>
> insmod the device, OK<br>
> rmmod the device, OK<br>
> Check /proc/devices , device # is present<br>
> insmod the device again, fails with ERROR: could not insert module<br>
> ./foobar.ko: Device or resource busy<br>
<br>
</div>It does smell like an unregister issue. You may want to try adding<br>
printk() calls to print out the return code from register and unregister.<br>
I'm willing to bet that (a) the unegister is failing because somebody<br>
still has a reference on the device, and (b) the second register call fails<br>
because the device already exists, causing your module_init() to bail out.<br>
<br>
The fun is that you may not have taken a reference on the device directly<br>
yourself - you may have called some other get_foo() that ends up taking an<br>
implicit reference under the covers, causing issues when you fail to call<br>
put_foo() at the right place...<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">cc:NSA<br></div>
</div>