From patchwork Fri Dec 1 10:46:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunjian Wang X-Patchwork-Id: 134744 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 03F054341B; Fri, 1 Dec 2023 11:46:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9DB3F402B9; Fri, 1 Dec 2023 11:46:57 +0100 (CET) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id A0DD940289; Fri, 1 Dec 2023 11:46:55 +0100 (CET) Received: from dggpemm500008.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4ShV484FrQzMnft; Fri, 1 Dec 2023 18:42:00 +0800 (CST) Received: from localhost (10.174.242.157) by dggpemm500008.china.huawei.com (7.185.36.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 1 Dec 2023 18:46:53 +0800 From: Yunjian Wang To: CC: , , , , Yunjian Wang , Subject: [PATCH 1/1] net/iavf: fix memoy leak in error path Date: Fri, 1 Dec 2023 18:46:49 +0800 Message-ID: <2be401c77779bdc38c8a79b006665ba623c6e2db.1701426993.git.wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.174.242.157] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500008.china.huawei.com (7.185.36.136) X-CFilter-Loop: Reflected 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 In iavf_security_ctx_create() allocated memory for the 'security_ctx', we should free it when memory malloc for the 'iavf_security_ctx' fails, otherwise it will lead to memory leak. Fixes: 6bc987ecb860 ("net/iavf: support IPsec inline crypto") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang Acked-by: Qi Zhang --- drivers/net/iavf/iavf_ipsec_crypto.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/iavf/iavf_ipsec_crypto.c b/drivers/net/iavf/iavf_ipsec_crypto.c index 07a69db540..d6c0180ffd 100644 --- a/drivers/net/iavf/iavf_ipsec_crypto.c +++ b/drivers/net/iavf/iavf_ipsec_crypto.c @@ -1518,8 +1518,11 @@ iavf_security_ctx_create(struct iavf_adapter *adapter) if (adapter->security_ctx == NULL) { adapter->security_ctx = rte_malloc("iavf_security_ctx", sizeof(struct iavf_security_ctx), 0); - if (adapter->security_ctx == NULL) + if (adapter->security_ctx == NULL) { + rte_free(adapter->vf.eth_dev->security_ctx); + adapter->vf.eth_dev->security_ctx = NULL; return -ENOMEM; + } } return 0;