lin-bus / linux-lin

Linux kernel LIN bus support implemented as TTY line discipline for generic UART conrollers, documentation https://github.com/lin-bus/linux-lin/wiki, based on https://github.com/lin-bus/linux-lin/wiki/sllin-rtlws14-paper.pdf, more CAN related projects http://canbus.pages.fel.cvut.cz/
https://github.com/lin-bus/linux-lin/wiki
38 stars 26 forks source link

Avoid kernel oops when restoring line discipline #14

Closed vengaer closed 2 years ago

vengaer commented 2 years ago

There is an excess call to free_netdev in the sll_free_netdev which results in a kernel oops when either explicitly restroring the line discipline or unloading the module. Starting with 4.11.9 this is handled internally in netdev_run_todo in net/core/dev.c after setting needs_free_netdev. For versions before 4.11.9, there is already a call to netdev_free in sll_free_netdev.

67a08d3 is more of a cosmetic suggestion which probably doesn't have too much of an impact on anything. Still, I'd argue it's a worthwhile change to avoid potential future mishaps.

ppisa commented 2 years ago

Thanks much for testing and fixes proposal.

I have pushed

sllin: Free netdev once

into master it is obviously correct and bug has been introduced when I have cherry-picked changes from Kyle's patch

sslin: update initialization to be compatible with 4,12+ and 5.4+ kernels

because I have tried to keep compatibility with all kernels and overlooked that that the free has been left there twice.

As for the other patch, I am going through code. I see no other reference to the sllin kwthread then in sllin_close and I hope that concurrent call to sllin_close in a parallel to sllin_open_common is prevented by lock on UART level. So I will merge other patch as well.