]> git.baikalelectronics.ru Git - kernel.git/commit
net: fec: fix use-after-free in fec_drv_remove
authorPavel Skripkin <paskripkin@gmail.com>
Wed, 4 Aug 2021 15:51:51 +0000 (18:51 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 5 Aug 2021 14:29:49 +0000 (07:29 -0700)
commit44712965bf12ae1758cec4de53816ed4b914ca1a
tree18e6a326e54544210ed88dafa79cd77e1546e27c
parentaf35fc37354cda3c9c8cc4961b1d24bdc9d27903
net: fec: fix use-after-free in fec_drv_remove

Smatch says:
drivers/net/ethernet/freescale/fec_main.c:3994 fec_drv_remove() error: Using fep after free_{netdev,candev}(ndev);
drivers/net/ethernet/freescale/fec_main.c:3995 fec_drv_remove() error: Using fep after free_{netdev,candev}(ndev);

Since fep pointer is netdev private data, accessing it after free_netdev()
call can cause use-after-free bug. Fix it by moving free_netdev() call at
the end of the function

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: a31eda65ba21 ("net: fec: fix clock count mis-match")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Reviewed-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/freescale/fec_main.c