From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 26698A034F; Tue, 1 Mar 2022 21:33:07 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3D9240696; Tue, 1 Mar 2022 21:33:06 +0100 (CET) Received: from out203-205-251-73.mail.qq.com (out203-205-251-73.mail.qq.com [203.205.251.73]) by mails.dpdk.org (Postfix) with ESMTP id 0EA9A40040 for ; Tue, 1 Mar 2022 21:33:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1646166781; bh=/gFqa6ka9i7e2OdHt83aAbC6s4z+N/Yoy/WBotDoqtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Cy2DK90X0BHKNsTN6MF+Tpf1Y0MDyV1xaBtoVNRPZwOJRkGBAbjlXNPaDFvyoj2hD ErtkiyDovuL1IGk9Ld+6a/LEvpzyTQJL8yPBbOQJLPjVJ7Wyq1QgvXCW/v1TXWF837 HmGZ2cuaz2Daj3mdqujzRnkxa0F0LeMvdeoJs4qk= Received: from localhost.localdomain ([111.193.130.237]) by newxmesmtplogicsvrszc6.qq.com (NewEsmtp) with SMTP id 83A21C3B; Wed, 02 Mar 2022 04:32:58 +0800 X-QQ-mid: xmsmtpt1646166778tvb2gbuk7 Message-ID: X-QQ-XMAILINFO: MIAHdi1iQo+zUg7WeS4mROvDr402ULXFq/7s79sRDZHpqQJOjzBFpKbadVEVZM 8Ya4KpKMThCHpy6zB83K3rJdQqwREP4d2yNsKocF1FYBjrbF6CXce+9swnL8Zjisn64ikMzO0HrV 2by7SzoaXUb4ZXKoKQrimrQumCJaTt8Rb+X1Hj7J6eqof/b2yGjhe6SWr+DN57o03hKAMS3aQ1kv MWtOFa4Mq01PPZPVECLyblEnWiEaf8I5uwWPb4g13NUnLs5VQOr9ZCfFZjkLlNELau7nfTysbHy2 /s+EHXXpK/7soQrqH+ZpZ0qZpKBt5XTytj72gCipD4CfTkD4VgeYmEKiz+QHYia4Mzuaj1RJceay ouByC9h9uGAfyqySckOaOVGdT4u4fTXWiBVK5AS0Dy64rXEb3+x0yvg0moZE8DlmZ1rZsJQE60ay DbF5ZtM1ePkH/jYyA2Q/2WjU/VkINbCNWnQ900UC/CoCqfGUq3Hx/ucS1wlzPGw65y+X9zRNJNhp 3BiYrIveDJAjZZw1TGQtzd3j/FCS0a6HuvrOXYI4kSb/V1UkWzOAENmhAxb0vDAdO2cMUEyhusjN F9BVu5msCQGsqOsPf4Cn1GOEPX12Kux5UfCZX6K9uG/tcr6+sr06X9uQRRvbTSXhdV+RJ8ClQuSk VSuqv1KgybgKVudTuyFQZ6bMi5gDVPzwRcz0Z4sB0vzRxKaeNaPAQncZVQNVakSz6veT4RZvL86T ZU30OUhWYOGeWr619BPjXvBoRlVhuMBKEmhYXjhl/4Kdmc3gZA1MguQJBXriQ3WIXKqsEUVc8OGG Ky6rDQauy2Hwi844qoKlYd6ZGvSym5Q4VOWNNiHR0Y+rPJRrnFWGJHSrnmz8s3bbSsS/tpYaXUEw iJj5M3+qNOeMmoehoN2Zf3mqQoSrrIEXQiTu6qItbU From: Weiguo Li To: cristian.dumitrescu@intel.com Cc: jasvinder.singh@intel.com, dev@dpdk.org, Stephen Hemminger Subject: [PATCH v5] sched: remove useless malloc in pie data init Date: Wed, 2 Mar 2022 04:32:57 +0800 X-OQ-MSGID: <20220301203257.558211-1-liwg06@foxmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 'rte_pie_rt_data_init(NULL)' is not expected, and it's ought to fail when this happen. The malloc inside the function didn't work. So remove the malloc otherwise will lead to a memory leak. Fixes: 44c730b0e37971 ("sched: add PIE based congestion management") Signed-off-by: Weiguo Li Acked-by: Stephen Hemminger Acked-by: Cristian Dumitrescu --- v5: * fix compile error v4: * replace all assignments to zero by a memset. v3: * fix typo v2: * revise according to Stephen's suggestion. --- lib/sched/rte_pie.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c index cdb7bab697..d37b79e6dd 100644 --- a/lib/sched/rte_pie.c +++ b/lib/sched/rte_pie.c @@ -3,6 +3,7 @@ */ #include +#include #include "rte_pie.h" #include @@ -15,26 +16,11 @@ int rte_pie_rt_data_init(struct rte_pie *pie) { if (pie == NULL) { - /* Allocate memory to use the PIE data structure */ - pie = rte_malloc(NULL, sizeof(struct rte_pie), 0); - - if (pie == NULL) - RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__); - - return -1; + RTE_LOG(ERR, SCHED, "%s: Invalid addr for pie\n", __func__); + return -EINVAL; } - pie->active = 0; - pie->in_measurement = 0; - pie->departed_bytes_count = 0; - pie->start_measurement = 0; - pie->last_measurement = 0; - pie->qlen = 0; - pie->avg_dq_time = 0; - pie->burst_allowance = 0; - pie->qdelay_old = 0; - pie->drop_prob = 0; - pie->accu_prob = 0; + memset(pie, 0, sizeof(*pie)); return 0; } -- 2.25.1