Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/62410/?format=api
https://patches.dpdk.org/api/patches/62410/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20191104204347.62267-1-shougangx.wang@intel.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20191104204347.62267-1-shougangx.wang@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20191104204347.62267-1-shougangx.wang@intel.com", "date": "2019-11-04T20:43:47", "name": "net/ice: fix memory release in FDIR", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "3cdc2f011ed82c2ef4cd6eea35e25e8a3da4e7d3", "submitter": { "id": 1418, "url": "https://patches.dpdk.org/api/people/1418/?format=api", "name": "Shougang Wang", "email": "shougangx.wang@intel.com" }, "delegate": { "id": 31221, "url": "https://patches.dpdk.org/api/users/31221/?format=api", "username": "yexl", "first_name": "xiaolong", "last_name": "ye", "email": "xiaolong.ye@intel.com" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/20191104204347.62267-1-shougangx.wang@intel.com/mbox/", "series": [ { "id": 7233, "url": "https://patches.dpdk.org/api/series/7233/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=7233", "date": "2019-11-04T20:43:47", "name": "net/ice: fix memory release in FDIR", "version": 1, "mbox": "https://patches.dpdk.org/series/7233/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/62410/comments/", "check": "fail", "checks": "https://patches.dpdk.org/api/patches/62410/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id EBB02A04A2;\n\tTue, 5 Nov 2019 04:02:54 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id AD00E2C2B;\n\tTue, 5 Nov 2019 04:02:53 +0100 (CET)", "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by dpdk.org (Postfix) with ESMTP id BBFF02BF7;\n Tue, 5 Nov 2019 04:02:51 +0100 (CET)", "from fmsmga002.fm.intel.com ([10.253.24.26])\n by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n 04 Nov 2019 19:02:50 -0800", "from intel.sh.intel.com ([10.239.255.146])\n by fmsmga002.fm.intel.com with ESMTP; 04 Nov 2019 19:02:48 -0800" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.68,269,1569308400\"; d=\"scan'208\";a=\"232306408\"", "From": "Wang ShougangX <shougangx.wang@intel.com>", "To": "dev@dpdk.org", "Cc": "qiming.yang@intel.com, beilei.xing@intel.com, yahui.cao@intel.com,\n Wang ShougangX <shougangx.wang@intel.com>, stable@dpdk.org", "Date": "Mon, 4 Nov 2019 20:43:47 +0000", "Message-Id": "<20191104204347.62267-1-shougangx.wang@intel.com>", "X-Mailer": "git-send-email 2.17.1", "Subject": "[dpdk-dev] [PATCH] net/ice: fix memory release in FDIR", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "To avoid wild pointer and memory leak, following resources management\nshould be added.\n- Check if the FDIR Memzone already exists before reserving.\n- Free FDIR memzone when teardown and other failure scenarios.\n- Set pointers to NULL after free them.\n- Release all counter resources when teardown.\n\nFixes: 84dc7a95a2d3 (\"net/ice: enable flow director engine\")\nFixes: 0f880c3df192 (\"net/ice: add flow director counter resource init/release\")\nCc: stable@dpdk.org\n\nSigned-off-by: Wang ShougangX <shougangx.wang@intel.com>\n---\n drivers/net/ice/ice_ethdev.h | 1 +\n drivers/net/ice/ice_fdir_filter.c | 41 ++++++++++++++++++++++++++++---\n 2 files changed, 38 insertions(+), 4 deletions(-)", "diff": "diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h\nindex de67e5934..0a39ca6ff 100644\n--- a/drivers/net/ice/ice_ethdev.h\n+++ b/drivers/net/ice/ice_ethdev.h\n@@ -325,6 +325,7 @@ struct ice_fdir_info {\n \tstruct ice_rx_queue *rxq;\n \tvoid *prg_pkt; /* memory for fdir program packet */\n \tuint64_t dma_addr; /* physic address of packet memory*/\n+\tconst struct rte_memzone *mz;\n \tstruct ice_fdir_filter_conf conf;\n \n \tstruct ice_fdir_filter_conf **hash_map;\ndiff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c\nindex 736ccd54e..059a579dc 100644\n--- a/drivers/net/ice/ice_fdir_filter.c\n+++ b/drivers/net/ice/ice_fdir_filter.c\n@@ -140,6 +140,12 @@ static struct ice_flow_parser ice_fdir_parser_comms;\n static const struct rte_memzone *\n ice_memzone_reserve(const char *name, uint32_t len, int socket_id)\n {\n+\tconst struct rte_memzone *mz;\n+\n+\tmz = rte_memzone_lookup(name);\n+\tif (mz)\n+\t\treturn mz;\n+\n \treturn rte_memzone_reserve_aligned(name, len, socket_id,\n \t\t\t\t\t RTE_MEMZONE_IOVA_CONTIG,\n \t\t\t\t\t ICE_RING_BASE_ALIGN);\n@@ -159,6 +165,10 @@ ice_fdir_prof_alloc(struct ice_hw *hw)\n \t\tif (!hw->fdir_prof)\n \t\t\treturn -ENOMEM;\n \t}\n+\n+\t/* To avoid wild pointer, unused field pointer should be NULL */\n+\thw->fdir_prof[ICE_FLTR_PTYPE_NONF_NONE] = NULL;\n+\n \tfor (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;\n \t ptype < ICE_FLTR_PTYPE_MAX;\n \t ptype++) {\n@@ -177,6 +187,7 @@ ice_fdir_prof_alloc(struct ice_hw *hw)\n \t fltr_ptype++)\n \t\trte_free(hw->fdir_prof[fltr_ptype]);\n \trte_free(hw->fdir_prof);\n+\thw->fdir_prof = NULL;\n \treturn -ENOMEM;\n }\n \n@@ -256,8 +267,13 @@ ice_fdir_counter_release(struct ice_pf *pf)\n \t\t\t\t&fdir_info->counter;\n \tuint8_t i;\n \n-\tfor (i = 0; i < container->index_free; i++)\n+\tfor (i = 0; i < container->index_free; i++) {\n \t\trte_free(container->pools[i]);\n+\t\tcontainer->pools[i] = NULL;\n+\t}\n+\n+\tTAILQ_INIT(&container->pool_list);\n+\tcontainer->index_free = 0;\n \n \treturn 0;\n }\n@@ -403,6 +419,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)\n \t\trte_free(fdir_info->hash_map);\n \tif (fdir_info->hash_table)\n \t\trte_hash_free(fdir_info->hash_table);\n+\n+\tfdir_info->hash_map = NULL;\n+\tfdir_info->hash_table = NULL;\n }\n \n /*\n@@ -493,19 +512,23 @@ ice_fdir_setup(struct ice_pf *pf)\n \t}\n \tpf->fdir.prg_pkt = mz->addr;\n \tpf->fdir.dma_addr = mz->iova;\n+\tpf->fdir.mz = mz;\n \n \terr = ice_fdir_prof_alloc(hw);\n \tif (err) {\n \t\tPMD_DRV_LOG(ERR, \"Cannot allocate memory for \"\n \t\t\t \"flow director profile.\");\n \t\terr = -ENOMEM;\n-\t\tgoto fail_mem;\n+\t\tgoto fail_prof;\n \t}\n \n \tPMD_DRV_LOG(INFO, \"FDIR setup successfully, with programming queue %u.\",\n \t\t vsi->base_queue);\n \treturn ICE_SUCCESS;\n \n+fail_prof:\n+\trte_memzone_free(pf->fdir.mz);\n+\tpf->fdir.mz = NULL;\n fail_mem:\n \tice_rx_queue_release(pf->fdir.rxq);\n \tpf->fdir.rxq = NULL;\n@@ -525,10 +548,13 @@ ice_fdir_prof_free(struct ice_hw *hw)\n \n \tfor (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;\n \t ptype < ICE_FLTR_PTYPE_MAX;\n-\t ptype++)\n+\t ptype++) {\n \t\trte_free(hw->fdir_prof[ptype]);\n+\t\thw->fdir_prof[ptype] = NULL;\n+\t}\n \n \trte_free(hw->fdir_prof);\n+\thw->fdir_prof = NULL;\n }\n \n /* Remove a profile for some filter type */\n@@ -573,7 +599,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf)\n {\n \tenum ice_fltr_ptype ptype;\n \n-\tfor (ptype = ICE_FLTR_PTYPE_NONF_NONE;\n+\tfor (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;\n \t ptype < ICE_FLTR_PTYPE_MAX;\n \t ptype++) {\n \t\tice_fdir_prof_rm(pf, ptype, false);\n@@ -619,6 +645,13 @@ ice_fdir_teardown(struct ice_pf *pf)\n \tice_fdir_prof_free(hw);\n \tice_release_vsi(vsi);\n \tpf->fdir.fdir_vsi = NULL;\n+\n+\tif (pf->fdir.mz) {\n+\t\terr = rte_memzone_free(pf->fdir.mz);\n+\t\tpf->fdir.mz = NULL;\n+\t\tif (err)\n+\t\t\tPMD_DRV_LOG(ERR, \"Failed to free memezone.\");\n+\t}\n }\n \n static int\n", "prefixes": [] }{ "id": 62410, "url": "