diff options
author | hselasky <hselasky@FreeBSD.org> | 2017-05-19 13:02:19 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2017-05-19 13:02:19 +0000 |
commit | 60d6e0e8f1794c59127512c69e8087ea27acc94c (patch) | |
tree | 87d4086b330babe6f9039c2afadebd64e741b530 /sys/ofed | |
parent | d4abc48636197de10c68e45f850656afb8222d61 (diff) | |
download | FreeBSD-src-60d6e0e8f1794c59127512c69e8087ea27acc94c.zip FreeBSD-src-60d6e0e8f1794c59127512c69e8087ea27acc94c.tar.gz |
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
Diffstat (limited to 'sys/ofed')
-rw-r--r-- | sys/ofed/drivers/net/mlx4/en_netdev.c | 13 | ||||
-rw-r--r-- | sys/ofed/drivers/net/mlx4/mlx4_en.h | 3 |
2 files changed, 8 insertions, 8 deletions
diff --git a/sys/ofed/drivers/net/mlx4/en_netdev.c b/sys/ofed/drivers/net/mlx4/en_netdev.c index 26a0c6c..5aa604f 100644 --- a/sys/ofed/drivers/net/mlx4/en_netdev.c +++ b/sys/ofed/drivers/net/mlx4/en_netdev.c @@ -1639,7 +1639,7 @@ void mlx4_en_free_resources(struct mlx4_en_priv *priv) mlx4_en_destroy_cq(priv, &priv->rx_cq[i]); } - if (priv->sysctl) + if (priv->stat_sysctl != NULL) sysctl_ctx_free(&priv->stat_ctx); } @@ -1754,7 +1754,7 @@ void mlx4_en_destroy_netdev(struct net_device *dev) 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); @@ -2573,9 +2573,9 @@ static void mlx4_en_sysctl_conf(struct mlx4_en_priv *priv) 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); @@ -2638,7 +2638,6 @@ static void mlx4_en_sysctl_conf(struct mlx4_en_priv *priv) 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; @@ -2649,9 +2648,9 @@ static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv) 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, diff --git a/sys/ofed/drivers/net/mlx4/mlx4_en.h b/sys/ofed/drivers/net/mlx4/mlx4_en.h index 17afa9e..5c800fd 100644 --- a/sys/ofed/drivers/net/mlx4/mlx4_en.h +++ b/sys/ofed/drivers/net/mlx4/mlx4_en.h @@ -587,7 +587,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 |