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 DEC9AA034E; Tue, 22 Feb 2022 19:18:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 833D740DF6; Tue, 22 Feb 2022 19:18:34 +0100 (CET) Received: from out203-205-221-235.mail.qq.com (out203-205-221-235.mail.qq.com [203.205.221.235]) by mails.dpdk.org (Postfix) with ESMTP id D608140DF4 for ; Tue, 22 Feb 2022 19:18:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1645553909; bh=BbEvK2SNRoVnBKbnGvXZnjoc5O7HHTi+WbMMPrq5qic=; h=From:To:Cc:Subject:Date; b=LRBjnOaT1Xq/W51HkgOd4nQoZbWRp1TaGbi4emTCOPgkq3bJlqVbauYsLTNrrIC+h k2ZwSkwY8h8wefvs3pN7XMDrrREbgADsjDQMlrD2mMHbPgX1nqly/b0sJn+A/ILrgb 8w5MD+YSJUq0JEqub3ZuxcUdDw6eT1id1434c6UA= Received: from localhost.localdomain ([111.193.130.237]) by newxmesmtplogicsvrszc6.qq.com (NewEsmtp) with SMTP id 49223207; Wed, 23 Feb 2022 02:18:18 +0800 X-QQ-mid: xmsmtpt1645553898tsmh9awn9 Message-ID: X-QQ-XMAILINFO: OZ7HbAk7YCRi34tNTEdTEfFRRt+ZC1b4cSKSSjpZQ9NrjCdyw83yiSXcI8Kj9P 8R/EaXdcdzFxO+7zcTcUNAkbmRApeOCMwSM0ZrxbV+sJ5nojOPzrGJNuV897bRcZKHr6xuUS9OWp 85BKkn8oS5gFBFZUa5BnKkTv55OipXsHNgPcWOfdvWcGuSDSqxgURrkacZqH8VBcYA3BtFSgIgHA DkmVPxACfssS4M4vFb46owBk3WRQClOL4d+Np1bFVO9C6pkavgi0+fcXWDVCfHOxjbXtkG7HxJbS 7MZZDEuTTmLAx+PVLWO0GXzB5S0K5MxADr1qoxrH5GHmY1EMn4vKw7LES2wBKBWCjY8qfprAbcag 8FVSSXJ+rXD6nst86S+jYiDTKuRGRx7rnHkkQovXUn/+Lks3X305qzcNKQ7myZXOE7IbBb4S77IY sghRM07bn6DtljwvapIurKRfNcT70MTDAHfLzeHGgtlYuedPQI7iLgIQj4hJWzpaFTJDuDHUlMKA ClZKRwSY1Ma5z5nGh+/l7G/4vosjtWYI60IONumwSwtfcD3VaMOeZpknnxJzaRkJFxOW43z6B+Jk YFFTkthgU552E4IqjndPYz8vgJyW0djxSSQvucaM5rbYEQ6/SrfyfySp1Cp6dICTrPt0GbhRfm5h fIkuD52mGat02GOSjAc4UyZ4FzpqOlO4Pg8eep+7S2NvyroNzXF59NOUnDTLCeJta/a8rCGnH0ZP QPLciKtATq6FNIsfGyNkJ19Wvhgdlh1Yk3bkUP9BGFUCp9MN2uYTVRuXUGLTedCJXdiDQBgYssth eXFHvRHJRESPgr6WwGhgrkIRoX5CrvCOOImryxUOvAzpkmrkYhU1UHOgvQOdjDoa0= From: Weiguo Li To: dev@dpdk.org Cc: adypodoman@gmail.com, xiaoyun.li@intel.com, tianfei.zhang@intel.com, bruce.richardson@intel.com, ivan.malov@oktetlabs.ru, jgrajcia@cisco.com, hkalra@marvell.com, ying.a.wang@intel.com, ting.xu@intel.com, simei.su@intel.com, qiming.yang@intel.com, motih@mellanox.com, shreyansh.jain@nxp.com, skoteshwar@marvell.com, stephen@networkplumber.org, kalesh-anakkur.purayil@broadcom.com, somnath.kotur@broadcom.com, declan.doherty@intel.com, gakhil@marvell.com, nicolas.chautru@intel.com Subject: [PATCH 00/20] fix memory leaks in error handling Date: Wed, 23 Feb 2022 02:17:58 +0800 X-OQ-MSGID: X-Mailer: git-send-email 2.25.1 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 This series fix some memory leaks in error handling. I write a coccinelle script to detect these issues, and fix them after exclude a small number of false positives. FYI, the script is as follows: // // Find possible memory leaks in error handling // Reference: coccinellery/alloc9/kmalloc9.cocci // @memory_leak_in_error_handling @ local idexpression x; expression E; statement S; identifier dpdk_malloc = { rte_malloc, rte_zmalloc, rte_realloc, rte_malloc_socket, rte_zmalloc_socket, rte_realloc_socket, rte_pktmbuf_alloc, opae_malloc, strdup, strndup, malloc, realloc, calloc }; identifier dpdk_free = { rte_free, free, bnx2x_rx_queue_release, bnx2x_tx_queue_release, rte_pktmbuf_free, opae_free, ntb_rxq_release, ntb_txq_release, ice_rx_queue_release, ice_tx_queue_release }; type T; @@ ( /* skip this pattern to reduce false positives */ x = dpdk_malloc(...); ... if (...) { ... \( return x; \| return 0; \) } | * x = dpdk_malloc(...); ... if (x == NULL) S ... when != E = x when != dpdk_free (..., \( x \| (T)x \| &x \), ...) when forall if (...) { <+... when != E = x when != dpdk_free (..., \( x \| (T)x \| &x \), ...) when forall * return ...; ...+> } ) Weiguo Li (20): baseband/acc100: fix a memory leak in acc100 queue setup common/dpaax: fix a memory leak in iterate dir crypto/dpaa2_sec: fix memory leaks in error handlings crypto/qat: fix a memory leak when set encrypt key fail net/bnxt: fix a memory leak in error handling net/bnxt: fix 'ctx' memory leak when new malloc fail net/bnx2x: add clean up for 'rxq' to avoid a memory leak net/cnxk: free 'node' memory when node add fail net/dpaa: fix a memory leak when validation fail net/failsafe: fix a memory leak in error handling net/iavf: fix a memory leak in error handling net/ice: goto clean up lable to avoid memory leak net/ice: fix memory leaks in error handlings net/ice: avoid fix memory leaks in register parser net/memif: fix some memory leaks in error handlings net/sfc: fix a memory leak in error handling net/vmxnet3: fix memory leaks in error handlings raw/ifpga/base: fix memory leaks in error handlings raw/ntb: fix some memory leaks in error handlings regex/mlx5: fix a memory leak in error handling drivers/baseband/acc100/rte_acc100_pmd.c | 8 +++--- drivers/common/dpaax/dpaa_of.c | 4 ++- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 3 ++ drivers/crypto/qat/qat_sym_session.c | 9 +++--- drivers/net/bnx2x/bnx2x_rxtx.c | 1 + drivers/net/bnxt/bnxt_hwrm.c | 1 + drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 1 + drivers/net/cnxk/cnxk_tm.c | 1 + drivers/net/dpaa/dpaa_rxtx.c | 1 + drivers/net/failsafe/failsafe_ops.c | 1 + drivers/net/iavf/iavf_generic_flow.c | 1 + drivers/net/ice/ice_acl_filter.c | 2 +- drivers/net/ice/ice_generic_flow.c | 9 +++--- drivers/net/ice/ice_hash.c | 30 ++++++++++++------- drivers/net/memif/rte_eth_memif.c | 32 ++++++++++++++------- drivers/net/sfc/sfc.c | 4 ++- drivers/net/vmxnet3/vmxnet3_rxtx.c | 8 ++++++ drivers/raw/ifpga/base/ifpga_enumerate.c | 10 +++++-- drivers/raw/ifpga/base/opae_eth_group.c | 1 + drivers/raw/ifpga/base/opae_i2c.c | 5 +++- drivers/raw/ntb/ntb.c | 9 +++--- drivers/regex/mlx5/mlx5_rxp.c | 4 ++- 22 files changed, 100 insertions(+), 45 deletions(-) -- 2.25.1