Problem with line discipline in new kernels
Ruth Glushkin
rutigl at gmail.com
Sun Aug 23 03:14:20 EDT 2015
On Thu, 22 Aug 2015 00:21:00 -0000, Valdis Kletnieks said:
> Sounds like a reference counting problem.
As far as I know, reference counter for line discipline sets to 0 in
tty_register_ldisc(),
increases to 1 in get_ldops() and decreases to 1 in put_ldops().
In tty_unregister_ldisc() it checks this value and if the reference
counter > 0, it returns error -EBUSY
And please advice how could I transfer data between kernel and user
space not using filp_open() and filp_close().
2015-08-22 0:21 GMT+03:00 <Valdis.Kletnieks at vt.edu>:
> On Thu, 13 Aug 2015 13:00:58 -0000, Margarita Glushkin said:
>> I have a linux kernel driver for serial device, which uses line discipline
>> and char device. Driver works with all old kernels, starting from 3.8 this
>> driver still works, but when I unload it and load again to the memory
>> (modprobe -r bpsctl_mod, after modprobe bpsctl_mod), it crashes the kernel.
>> It can't unregister line discipline, because this line discipline is busy.
>
> Sounds like a reference counting problem. When your line discipline is busy,
> somebody should have a reference on the module so it can't be unloaded. I don't
> see any such reference taking/freeing in your posted code.
>
> Your crash is almost certainly because you're unloading it out from
> under active use, which will probably result in somebody overlaying storage.
> Frankly, you're probably lucky the system lives long enough for you to
> reload it.....
>
> Oh, and filp_open() is usually the wrong way to solve whatever problem you
> were trying to solve by using it.
More information about the Kernelnewbies
mailing list