]> git.baikalelectronics.ru Git - kernel.git/commit
net: alx: fix race condition in alx_remove
authorZekun Shen <bruceshenzk@gmail.com>
Mon, 15 Jun 2020 15:50:29 +0000 (11:50 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 Jun 2020 20:20:14 +0000 (13:20 -0700)
commit4243591e5f9f097b7ee7e03b9e4a67d2cb9ac421
tree2c73ec0ca58c7e7e2e2efc60f4b4cefc0b510702
parentac8020063be12d498d8ef47e9431d85bbc2813f4
net: alx: fix race condition in alx_remove

There is a race condition exist during termination. The path is
alx_stop and then alx_remove. An alx_schedule_link_check could be called
before alx_stop by interrupt handler and invoke alx_link_check later.
Alx_stop frees the napis, and alx_remove cancels any pending works.
If any of the work is scheduled before termination and invoked before
alx_remove, a null-ptr-deref occurs because both expect alx->napis[i].

This patch fix the race condition by moving cancel_work_sync functions
before alx_free_napis inside alx_stop. Because interrupt handler can call
alx_schedule_link_check again, alx_free_irq is moved before
cancel_work_sync calls too.

Signed-off-by: Zekun Shen <bruceshenzk@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/atheros/alx/main.c