summaryrefslogtreecommitdiffstats
path: root/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2016-08-15 09:07:26 +0000
committerhselasky <hselasky@FreeBSD.org>2016-08-15 09:07:26 +0000
commit12f048fb0e3f3ae7a9b1e3497559411903fc6d00 (patch)
treee6112e78ce2b144de97a945426d0b80efa5f3f84 /sys/dev/mlx5/mlx5_en/mlx5_en_main.c
parente0da58dcb669cc6c19e28ac9deaebfdb07471fe9 (diff)
downloadFreeBSD-src-12f048fb0e3f3ae7a9b1e3497559411903fc6d00.zip
FreeBSD-src-12f048fb0e3f3ae7a9b1e3497559411903fc6d00.tar.gz
MFC r303870:
Fix for use after free. Clear the device description to avoid use after free because the bsddev is not destroyed when the mlx5en module is unloaded. Only when the parent mlx5 module is unloaded the bsddev is destroyed. This fixes a panic on listing sysctls which refer strings in the bsddev after the mlx5en module has been unloaded. Sponsored by: Mellanox Technologies
Diffstat (limited to 'sys/dev/mlx5/mlx5_en/mlx5_en_main.c')
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_main.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
index 47d96b4..2136567 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
@@ -3108,6 +3108,13 @@ mlx5e_destroy_ifp(struct mlx5_core_dev *mdev, void *vpriv)
/* don't allow more IOCTLs */
priv->gone = 1;
+ /*
+ * Clear the device description to avoid use after free,
+ * because the bsddev is not destroyed when this module is
+ * unloaded:
+ */
+ device_set_desc(mdev->pdev->dev.bsddev, NULL);
+
/* XXX wait a bit to allow IOCTL handlers to complete */
pause("W", hz);
OpenPOWER on IntegriCloud