svn commit: r341546 - head/sys/dev/mlx4/mlx4_core

Slava Shwartsman slavash at FreeBSD.org
Wed Dec 5 13:31:15 UTC 2018


Author: slavash
Date: Wed Dec  5 13:31:14 2018
New Revision: 341546
URL: https://svnweb.freebsd.org/changeset/base/341546

Log:
  mlx4en: Add driver version to sysctl desc
  
  Approved by:    hselasky (mentor)
  MFC after:      1 week
  Sponsored by:   Mellanox Technologies

Modified:
  head/sys/dev/mlx4/mlx4_core/mlx4_main.c

Modified: head/sys/dev/mlx4/mlx4_core/mlx4_main.c
==============================================================================
--- head/sys/dev/mlx4/mlx4_core/mlx4_main.c	Wed Dec  5 13:30:48 2018	(r341545)
+++ head/sys/dev/mlx4/mlx4_core/mlx4_main.c	Wed Dec  5 13:31:14 2018	(r341546)
@@ -121,6 +121,9 @@ MODULE_PARM_DESC(enable_4k_uar,
 
 #define RESET_PERSIST_MASK_FLAGS	(MLX4_FLAG_SRIOV)
 
+static char mlx4_description[] = "Mellanox driver"
+    " (" DRV_VERSION ")";
+
 static char mlx4_version[] =
 	DRV_NAME ": Mellanox ConnectX core driver v"
 	DRV_VERSION " (" DRV_RELDATE ")\n";
@@ -3780,6 +3783,7 @@ static int mlx4_init_one(struct pci_dev *pdev, const s
 		kfree(priv);
 		return ret;
 	} else {
+		device_set_desc(pdev->dev.bsddev, mlx4_description);
 		pci_save_state(pdev->dev.bsddev);
 	}
 
@@ -3907,6 +3911,13 @@ static void mlx4_remove_one(struct pci_dev *pdev)
 	mutex_lock(&persist->interface_state_mutex);
 	persist->interface_state |= MLX4_INTERFACE_STATE_DELETION;
 	mutex_unlock(&persist->interface_state_mutex);
+
+	/*
+	 * Clear the device description to avoid use after free,
+	 * because the bsddev is not destroyed when this module is
+	 * unloaded:
+	 */
+	device_set_desc(pdev->dev.bsddev, NULL);
 
 	/* Disabling SR-IOV is not allowed while there are active vf's */
 	if (mlx4_is_master(dev) && dev->flags & MLX4_FLAG_SRIOV) {


More information about the svn-src-head mailing list