svn commit: r318540 - stable/10/sys/ofed/drivers/net/mlx4

Hans Petter Selasky hselasky at FreeBSD.org
Fri May 19 13:04:11 UTC 2017


Author: hselasky
Date: Fri May 19 13:04:09 2017
New Revision: 318540
URL: https://svnweb.freebsd.org/changeset/base/318540

Log:
  MFC r317505:
  Don't free uninitialized sysctl contexts in the mlx4en driver. This
  can cause NULL pointer panics during failed device attach.
  
  Differential Revision:	https://reviews.freebsd.org/D8876
  Sponsored by:		Mellanox Technologies

Modified:
  stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c
  stable/10/sys/ofed/drivers/net/mlx4/mlx4_en.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c
==============================================================================
--- stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c	Fri May 19 13:04:05 2017	(r318539)
+++ stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c	Fri May 19 13:04:09 2017	(r318540)
@@ -1640,7 +1640,7 @@ void mlx4_en_free_resources(struct mlx4_
 			mlx4_en_destroy_cq(priv, &priv->rx_cq[i]);
 	}
 
-	if (priv->sysctl)
+	if (priv->stat_sysctl != NULL)
 		sysctl_ctx_free(&priv->stat_ctx);
 }
 
@@ -1755,7 +1755,7 @@ void mlx4_en_destroy_netdev(struct net_d
 	mlx4_en_free_resources(priv);
 
 	/* freeing the sysctl conf cannot be called from within mlx4_en_free_resources */
-	if (priv->sysctl)
+	if (priv->conf_sysctl != NULL)
 		sysctl_ctx_free(&priv->conf_ctx);
 
 	kfree(priv->tx_ring);
@@ -2572,9 +2572,9 @@ static void mlx4_en_sysctl_conf(struct m
 	pnameunit = device_get_nameunit(priv->mdev->pdev->dev.bsddev);
 
         sysctl_ctx_init(ctx);
-        priv->sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(_hw),
+        priv->conf_sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(_hw),
             OID_AUTO, dev->if_xname, CTLFLAG_RD, 0, "mlx4 10gig ethernet");
-        node = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->sysctl), OID_AUTO,
+        node = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->conf_sysctl), OID_AUTO,
             "conf", CTLFLAG_RD, NULL, "Configuration");
         node_list = SYSCTL_CHILDREN(node);
 
@@ -2637,7 +2637,6 @@ static void mlx4_en_sysctl_conf(struct m
 static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv)
 {
 	struct sysctl_ctx_list *ctx;
-	struct sysctl_oid *node;
 	struct sysctl_oid_list *node_list;
 	struct sysctl_oid *ring_node;
 	struct sysctl_oid_list *ring_list;
@@ -2648,9 +2647,9 @@ static void mlx4_en_sysctl_stat(struct m
 
 	ctx = &priv->stat_ctx;
 	sysctl_ctx_init(ctx);
-	node = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->sysctl), OID_AUTO,
+	priv->stat_sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->conf_sysctl), OID_AUTO,
 	    "stat", CTLFLAG_RD, NULL, "Statistics");
-	node_list = SYSCTL_CHILDREN(node);
+	node_list = SYSCTL_CHILDREN(priv->stat_sysctl);
 
 #ifdef MLX4_EN_PERF_STAT
 	SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "tx_poll", CTLFLAG_RD,

Modified: stable/10/sys/ofed/drivers/net/mlx4/mlx4_en.h
==============================================================================
--- stable/10/sys/ofed/drivers/net/mlx4/mlx4_en.h	Fri May 19 13:04:05 2017	(r318539)
+++ stable/10/sys/ofed/drivers/net/mlx4/mlx4_en.h	Fri May 19 13:04:09 2017	(r318540)
@@ -586,7 +586,8 @@ struct mlx4_en_priv {
 	struct callout watchdog_timer;
         struct ifmedia media;
 	volatile int blocked;
-	struct sysctl_oid *sysctl;
+	struct sysctl_oid *conf_sysctl;
+	struct sysctl_oid *stat_sysctl;
 	struct sysctl_ctx_list conf_ctx;
 	struct sysctl_ctx_list stat_ctx;
 #define MLX4_EN_MAC_HASH_IDX 5


More information about the svn-src-all mailing list