From owner-svn-src-head@freebsd.org Thu Apr 27 14:39:53 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 92E5FD53380; Thu, 27 Apr 2017 14:39:53 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6E500B11; Thu, 27 Apr 2017 14:39:53 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3REdqA0006205; Thu, 27 Apr 2017 14:39:52 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3REdqeI006203; Thu, 27 Apr 2017 14:39:52 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201704271439.v3REdqeI006203@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 27 Apr 2017 14:39:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317505 - head/sys/dev/mlx4/mlx4_en X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Apr 2017 14:39:53 -0000 Author: hselasky Date: Thu Apr 27 14:39:52 2017 New Revision: 317505 URL: https://svnweb.freebsd.org/changeset/base/317505 Log: 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 MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/dev/mlx4/mlx4_en/en.h head/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c Modified: head/sys/dev/mlx4/mlx4_en/en.h ============================================================================== --- head/sys/dev/mlx4/mlx4_en/en.h Thu Apr 27 14:29:21 2017 (r317504) +++ head/sys/dev/mlx4/mlx4_en/en.h Thu Apr 27 14:39:52 2017 (r317505) @@ -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 Modified: head/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c ============================================================================== --- head/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c Thu Apr 27 14:29:21 2017 (r317504) +++ head/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c Thu Apr 27 14:39:52 2017 (r317505) @@ -1639,7 +1639,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); } @@ -1754,7 +1754,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); @@ -2573,9 +2573,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); @@ -2638,7 +2638,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; @@ -2649,9 +2648,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,