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 4AAA5A00C3; Tue, 1 Mar 2022 19:59:27 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E74D640696; Tue, 1 Mar 2022 19:59:26 +0100 (CET) Received: from out203-205-251-82.mail.qq.com (out203-205-251-82.mail.qq.com [203.205.251.82]) by mails.dpdk.org (Postfix) with ESMTP id 3D60F40040 for ; Tue, 1 Mar 2022 19:59:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1646161159; bh=TzPqr1++iCrEtYrb/G3NtWtTct4WM5oL2TVlslw6xio=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uPThBJ8OseYjSh/MnzB2cDZL/s8czigBThplO5TkxnitylkDJLPk3I5FbKgiJbo7u Sd2gCL00MSAmyykuKicMmItcQ/v61yfP3Y5UWUck9f5iY7WfeUKTa3qNmjlIVKqKfR wUmUtpb9jXFtAPMiyQf6HRpVHCCBvXpEe3iwgjo8= Received: from localhost.localdomain ([111.193.130.237]) by newxmesmtplogicsvrszb7.qq.com (NewEsmtp) with SMTP id EA5B5E2C; Wed, 02 Mar 2022 02:58:37 +0800 X-QQ-mid: xmsmtpt1646161117twdi71zff Message-ID: X-QQ-XMAILINFO: NwFwz4tS/C+ePOW9oXMvYZ+xDJr5WwcT8Sve38VSnXHAciRJwOqOHsNQvIKQtk 9EOci1w8IkdCW1wu/y3wALEjdroaEdMxdUg4jykByfq5ADRlxUffdZ9xtm6U8gixVf/e2qAtimp1 cRcf6AydfbWzCzjnZjpWxY9CHE7iFt4t7Id2bNmRTyZq8xdRD93FozG1JiGAHwuQWFOc238SNobg iMM2F43GvadR+vCOSycwZPVgkdJZlYvuYCIeA4kkGnsqhgJVxG8p4mU6rLptVEfd1iBA7K7RHaSQ 28O/4Kuvkvr5J/S47dKfrHo74CKr8NFphfkyKsFGE6A57mTnY2yF2XAkkPpBxnRCc0Sj/GZaNyAl dIzvIp9DkGocTPlZQDCMokyqkByjj3VosbikpeqBzZEThxlRhxxmeQeWq1jP6rTlTNYOCE8pEUVT ICzvVZFkIziPExJtf773wBDNl3XteqxNtnZTKIvRkQaozHW/O99Kw5uyYvf6nFmzMgo0puwa61WW 7AayH/h7oeZ/iFZRDGRPNlZ9dXgQtzHMgSUYOnoiR/bRNQ2aiwEInGm5sk2TeVc8T27Z9ZXiWiYt Gc2EFwFtFK7G6J/JdWvmUrWIoBn2FFVDP7Q4uSai+TM/LBbH0qRJGpWHm4j4f0mbno1vmX+wkkgM GB0F/PgQx1gvJScBulc30iDBeJgmFyVm7n9FZS0rtXkw4mibBidNn4/cCgmEIEBM7dZybbz6cMl2 svCNF63mbwYjTxUhkFq3zeVq7gLv0fviDxzRMwq39QbBVEbFfJapCUV2TJ433Pq9/qPQCWT0BhHt /bxLsHcjEAvXPL6ZKu9NXwhMzQnn25E3E8CPGE2fHWr+dI5FXDAMmUcgY63nd1nZGbtZCtSc/6d4 On9l35jgiYYwi2bahbZG5H706mYSYzL94ViaSuPaZIwyCy1UhIy0YapaulBPG+FQ== From: Weiguo Li To: cristian.dumitrescu@intel.com Cc: jasvinder.singh@intel.com, wojciechx.liguzinski@intel.com, dev@dpdk.org, Stephen Hemminger Subject: [PATCH v4] sched: remove useless malloc in pie data init Date: Wed, 2 Mar 2022 02:58:37 +0800 X-OQ-MSGID: <20220301185837.502387-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 --- v4: * replace all assignments to zero by a memset. v3: * fix typo v2: * revise according to Stephen's suggestion. --- lib/sched/rte_pie.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c index cdb7bab697..05a456d7ac 100644 --- a/lib/sched/rte_pie.c +++ b/lib/sched/rte_pie.c @@ -15,26 +15,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