Skip to content

Commit

Permalink
can: af_can: can_exit(): add missing dev_remove_pack() of canxl_packet
Browse files Browse the repository at this point in the history
In can_init(), dev_add_pack(&canxl_packet) is added but not removed in
can_exit(). It breaks the packet handler list and can make kernel
panic when can_init() is called for the second time.

| > modprobe can && rmmod can
| > rmmod xxx && modprobe can
|
| BUG: unable to handle page fault for address: fffffbfff807d7f4
| RIP: 0010:dev_add_pack+0x133/0x1f0
| Call Trace:
|  <TASK>
|  can_init+0xaa/0x1000 [can]
|  do_one_initcall+0xd3/0x4e0
|  ...

Fixes: fb08cba ("can: canxl: update CAN infrastructure for CAN XL frames")
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://lore.kernel.org/all/20221031033053.37849-1-chenzhongjin@huawei.com
[mkl: adjust subject and commit message]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Chen Zhongjin authored and Marc Kleine-Budde committed Nov 7, 2022
1 parent c23fb2c commit a3335fa
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions net/can/af_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ static __init int can_init(void)
static __exit void can_exit(void)
{
/* protocol unregister */
dev_remove_pack(&canxl_packet);
dev_remove_pack(&canfd_packet);
dev_remove_pack(&can_packet);
sock_unregister(PF_CAN);
Expand Down

0 comments on commit a3335fa

Please sign in to comment.