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 245BFA0544; Thu, 2 Jun 2022 10:06:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F180840694; Thu, 2 Jun 2022 10:06:29 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 76EFD4021E for ; Thu, 2 Jun 2022 10:06:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654157187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xj1To2T5W7rZz+jO1dXjyK3Y9PF688QmYs1dpYKb4h0=; b=dRLHqyMMXCiAG3PKvSKoDOSZJExEz4dHVdv9ymvhg9YDUaGn5Wd9BAHbalbetoGSsqGzUY Q8gpLBWSVwgv0f2TivQAt7J/aU7O8l2UMUfFCjdoXgt4gi7G6C0oiyzprm29NRChxdOYm/ dcmYnpV8tCKUtioixP0UslO9Yf5fYdY= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-658-p6zKF5KSMZ-yJhtv-TtJ-A-1; Thu, 02 Jun 2022 04:06:26 -0400 X-MC-Unique: p6zKF5KSMZ-yJhtv-TtJ-A-1 Received: by mail-lj1-f197.google.com with SMTP id e22-20020a2e9e16000000b00253cd8911easo676030ljk.13 for ; Thu, 02 Jun 2022 01:06:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xj1To2T5W7rZz+jO1dXjyK3Y9PF688QmYs1dpYKb4h0=; b=sYekpns19wyrkgQxr1gmrL9OH17J9JZHOYznyGKsk5Of5cIPPLsRp73UguMknQuq6R RNuEMj68zJcBTpHTmTWKQ4AiWTDL5I3l91gPunaoiTxSGnpsvRaF1Pmes3PdO+JiDO9w HQDs9HNkbLeCdikPM61wAOJBIW9w0rc4HnD4/7n6gHWeWvmQRBqS2p0DLumsCPvmY4PC 16Xn4L3zhTgiTsDYvhzqQjAv+5NZS3gBTVeOJIKhBBkl4izb5Q9wDnTP/Pxlw8UIhOtE Yakxw5a2wKzoky8601qiwBgyXJHRNp1AJvdXTcj8GSMUqnZrkICcszI48lhEEbqhNgkn OKMA== X-Gm-Message-State: AOAM5339TBzkbBf2nM1gUtfA6xaNfaPaUKcOJrNurgJcFhqRNi28R6JY +r0h8y4KryIQJ0ysq42kHN2nvjXrtdEfH4ueyHtMjFXJLIizPhpg4EInG8l6EoX9hZFplWgDm4j glqKyKshMpBN1fIXaptQ= X-Received: by 2002:a05:6512:3f8c:b0:45d:cb2a:8779 with SMTP id x12-20020a0565123f8c00b0045dcb2a8779mr51830605lfa.499.1654157185102; Thu, 02 Jun 2022 01:06:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaJMWxEEoBnxq31em0JyY3BsoFS06BC9Kz6adFWwTDQtIlDz+ywZEnaJJn3HmM6+BtGeZqrlKjPZz4SRZ6ntA= X-Received: by 2002:a05:6512:3f8c:b0:45d:cb2a:8779 with SMTP id x12-20020a0565123f8c00b0045dcb2a8779mr51830569lfa.499.1654157184551; Thu, 02 Jun 2022 01:06:24 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Marchand Date: Thu, 2 Jun 2022 10:06:13 +0200 Message-ID: Subject: Re: [PATCH 00/20] fix memory leaks in error handling To: Xiaoyun Li , "Zhang, Tianfei" , simei , Satha Rao , Shreyansh Jain , motih@mellanox.com, Qiming Yang , Bruce Richardson , Ivan Malov , Jakub Grajciar , Declan Doherty , Somnath Kotur , Kalesh A P , Harman Kalra , Ying A Wang , "Xu, Ting" , Stephen Hemminger , Nicolas Chautru , Akhil Goyal Cc: dev , adypodoman@gmail.com, Weiguo Li Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" 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 On Tue, Feb 22, 2022 at 7:18 PM Weiguo Li wrote: > > 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 ...; > ...+> > } > ) Thanks for those who did reviews, but there are a lot of unattended fixes in this series. Reviews please! -- David Marchand