From patchwork Thu Jan 17 20:41:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Dalessandro X-Patchwork-Id: 10768997 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9FA211390 for ; Thu, 17 Jan 2019 20:41:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E959300EA for ; Thu, 17 Jan 2019 20:41:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82BDA300F1; Thu, 17 Jan 2019 20:41:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11537300EA for ; Thu, 17 Jan 2019 20:41:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728616AbfAQUlX (ORCPT ); Thu, 17 Jan 2019 15:41:23 -0500 Received: from mga07.intel.com ([134.134.136.100]:1213 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727402AbfAQUlX (ORCPT ); Thu, 17 Jan 2019 15:41:23 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jan 2019 12:41:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,489,1539673200"; d="scan'208";a="139197629" Received: from scymds01.sc.intel.com ([10.82.194.37]) by fmsmga001.fm.intel.com with ESMTP; 17 Jan 2019 12:41:22 -0800 Received: from scvm10.sc.intel.com (scvm10.sc.intel.com [10.82.195.27]) by scymds01.sc.intel.com with ESMTP id x0HKfMAY029805; Thu, 17 Jan 2019 12:41:22 -0800 Received: from scvm10.sc.intel.com (localhost [127.0.0.1]) by scvm10.sc.intel.com with ESMTP id x0HKfMFn032296; Thu, 17 Jan 2019 12:41:22 -0800 Subject: [PATCH for-rc 2/7] IB/hfi1: Use new API to deallocate vnic rdma-netdev in hfi1 driver From: Dennis Dalessandro To: jgg@ziepe.ca, dledford@redhat.com Cc: linux-rdma@vger.kernel.org, "Michael J. Ruhl" , Andrzej Witkowski Date: Thu, 17 Jan 2019 12:41:22 -0800 Message-ID: <20190117204117.30826.2346.stgit@scvm10.sc.intel.com> In-Reply-To: <20190117203920.30826.76720.stgit@scvm10.sc.intel.com> References: <20190117203920.30826.76720.stgit@scvm10.sc.intel.com> User-Agent: StGit/0.17.1-18-g2e886-dirty MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andrzej Witkowski VNIC uses the old deprecated path for freeing netdev private device information. This will lead to a memory leak (of netdev devices) and possibly incorrect cleanup behavior. Fix by using the new API in the VNIC code path. Fixes: 9f49a5b5c21d ("RDMA/netdev: Use priv_destructor for netdev cleanup") Reviewed-by: Michael J. Ruhl Signed-off-by: Andrzej Witkowski Signed-off-by: Dennis Dalessandro --- drivers/infiniband/hw/hfi1/vnic_main.c | 4 ++-- drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c | 5 ++--- include/rdma/ib_verbs.h | 7 ------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/vnic_main.c b/drivers/infiniband/hw/hfi1/vnic_main.c index a922db5..1d66c43 100644 --- a/drivers/infiniband/hw/hfi1/vnic_main.c +++ b/drivers/infiniband/hw/hfi1/vnic_main.c @@ -789,7 +789,6 @@ static void hfi1_vnic_free_rn(struct net_device *netdev) hfi1_vnic_deinit(vinfo); mutex_destroy(&vinfo->lock); - free_netdev(netdev); } struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device, @@ -826,7 +825,6 @@ struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device, vinfo->num_tx_q = dd->num_sdma; vinfo->num_rx_q = dd->num_vnic_contexts; vinfo->netdev = netdev; - rn->free_rdma_netdev = hfi1_vnic_free_rn; rn->set_id = hfi1_vnic_set_vesw_id; netdev->features = NETIF_F_HIGHDMA | NETIF_F_SG; @@ -834,6 +832,8 @@ struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device, netdev->vlan_features = netdev->features; netdev->watchdog_timeo = msecs_to_jiffies(HFI_TX_TIMEOUT_MS); netdev->netdev_ops = &hfi1_netdev_ops; + netdev->priv_destructor = hfi1_vnic_free_rn; + netdev->needs_free_netdev = true; mutex_init(&vinfo->lock); for (i = 0; i < vinfo->num_rx_q; i++) { diff --git a/drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c b/drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c index ae70cd1..e21dc73 100644 --- a/drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c +++ b/drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c @@ -382,7 +382,8 @@ struct opa_vnic_adapter *opa_vnic_add_netdev(struct ib_device *ibdev, mutex_destroy(&adapter->mactbl_lock); kfree(adapter); adapter_err: - rn->free_rdma_netdev(netdev); + netdev->priv_destructor(netdev); + free_netdev(netdev); return ERR_PTR(rc); } @@ -391,7 +392,6 @@ struct opa_vnic_adapter *opa_vnic_add_netdev(struct ib_device *ibdev, void opa_vnic_rem_netdev(struct opa_vnic_adapter *adapter) { struct net_device *netdev = adapter->netdev; - struct rdma_netdev *rn = netdev_priv(netdev); v_info("removing\n"); unregister_netdev(netdev); @@ -399,5 +399,4 @@ void opa_vnic_rem_netdev(struct opa_vnic_adapter *adapter) mutex_destroy(&adapter->lock); mutex_destroy(&adapter->mactbl_lock); kfree(adapter); - rn->free_rdma_netdev(netdev); } diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index a3ceed3..7539030 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2213,13 +2213,6 @@ struct rdma_netdev { struct ib_device *hca; u8 port_num; - /* - * cleanup function must be specified. - * FIXME: This is only used for OPA_VNIC and that usage should be - * removed too. - */ - void (*free_rdma_netdev)(struct net_device *netdev); - /* control functions */ void (*set_id)(struct net_device *netdev, int id); /* send packet */