From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 955AE4601A;
	Mon, 20 Jan 2025 19:07:26 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 06156427C4;
	Mon, 20 Jan 2025 19:06:16 +0100 (CET)
Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com
 [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTP id 771D7427B2
 for <dev@dpdk.org>; Mon, 20 Jan 2025 19:06:11 +0100 (CET)
Received: by mail-pj1-f45.google.com with SMTP id
 98e67ed59e1d1-2ee786b3277so6026668a91.1
 for <dev@dpdk.org>; Mon, 20 Jan 2025 10:06:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737396370;
 x=1738001170; darn=dpdk.org; 
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=oe6thpbvuTwlF6av708SoGl2MyK1WhQ3TjGxc0hY8D4=;
 b=oyASWUX8s/uBLxWTL9g5hfcVH5fe5FzkyTQAP/vTgG8c/n10Za+J/tl5onmh+ibKIs
 Z/QqWAAA4EaZ/kEZAync3+e3Ip0rOp1hutjeXAwCdxFXrCFMhisROz2+uLJYVpLHY+1U
 eV+wBEhnLw3NhOZ7Sz9a3mJN0IMt75F5jyIcs5ImDaewc43Zp+blRzQ0I4g5WyU+F1ug
 ARGRPGkTUYYCnxMcsPrHzDIlP9FUPKbQgmuninLhtah5qO+FBQRxwsmWXNZA8qaWlWnJ
 HsQP/FMnzp3wpyP/20JyDgo/FpERfdlr7CDTtgVVJIms7U3LtzMvvHjvxmu0YTqFoECL
 EAOw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1737396370; x=1738001170;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=oe6thpbvuTwlF6av708SoGl2MyK1WhQ3TjGxc0hY8D4=;
 b=u6wfdqBxtIyKAeJJwR8qQmJiTUCLoNt5HRFL8rxzxtzdA7uVi0frtVatmV474xpqG4
 4xJ73GyzSEOq3AW4kWJC55XdOf1tnUaEMbA49vHOV7Dq+WIYoAuuGHbpXvwsMJL20QGg
 8t8+aowdB1L9C30d9432w1fiMMaLZayZOdwMXvo4gVxMu6ux+csl5INk630MkJ9Tb2om
 FRPP8lZt3QccbyW2qKo2Msa5gzUl/fCgYIDnnzCOT0bCPm9KWclrmTvBLN8nmTjzIZsI
 GBjyOwVM0+iaotukifVrLUAV+931jeyE+qCG/gKGRAaQIrYuiajPI59wCOSOqsKel/lt
 C0vQ==
X-Gm-Message-State: AOJu0YwoeL/nlJ0ivrXhp9C7+gRVqYgjbcoHL5ioWxeeW+rdpoONwK/e
 BJ2rkcwLTba/aJc/liL7Ufd8m00XDWdQFZHu+LxwWkVnpgfbeCS/aKcRIkQxL24hE7NIcUdOXNo
 t
X-Gm-Gg: ASbGnctZNFKu2G5u5KWP/TEzk0gwPRl73AhoEJIqrLXL2BQ1LNZ0ggv2S1Bhq/MLWAd
 YVWsl7SIYs4m9kvcgfNuTMb4OyrxA6mS3XTWPkxDdM+HJ8UcPva38vjKMKDvv9hFdEaDdgK8gWw
 hwUh3UHzzLwq2R8Lgkc26cfnEkal9xtuOELwhNSFwmN7PVwEF7SnREqwupYq1ysDsumL8RairEO
 OYRha+8CFRpmmPAURXq05yoEoK2ht9b/6vLBoUBxHz6c8smG+xa8OFENDm0RZ0TpPVMG4lQBj9B
 BGa/OleLaVu6oTNJnUF6X9RBpIc/pStapqmEDKFghJxvR2w=
X-Google-Smtp-Source: AGHT+IEGBg9gnoDcHxu2ZQTITL5ONNUNJ8o6vCXo/ZUArdIzbyGUkIUulpO0Mm9vWOhiJeyKutCNVQ==
X-Received: by 2002:a05:6a00:2444:b0:727:d55e:4bee with SMTP id
 d2e1a72fcca58-72daf92b010mr19187571b3a.1.1737396369832; 
 Mon, 20 Jan 2025 10:06:09 -0800 (PST)
Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])
 by smtp.gmail.com with ESMTPSA id
 d2e1a72fcca58-72dab848b08sm7393982b3a.71.2025.01.20.10.06.09
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 20 Jan 2025 10:06:09 -0800 (PST)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
 Fan Zhang <fanzhang.oss@gmail.com>, Ashish Gupta <ashish.gupta@marvell.com>
Subject: [PATCH 13/15] compressdev: add allocation function attributes
Date: Mon, 20 Jan 2025 10:03:31 -0800
Message-ID: <20250120180550.198121-14-stephen@networkplumber.org>
X-Mailer: git-send-email 2.45.2
In-Reply-To: <20250120180550.198121-1-stephen@networkplumber.org>
References: <20250120180550.198121-1-stephen@networkplumber.org>
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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Use function attributes to catch cases where compressdev is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/compressdev/rte_comp.h | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/lib/compressdev/rte_comp.h b/lib/compressdev/rte_comp.h
index d66a4b1cb9..f86e773b28 100644
--- a/lib/compressdev/rte_comp.h
+++ b/lib/compressdev/rte_comp.h
@@ -480,6 +480,19 @@ struct __rte_cache_aligned rte_comp_op {
 	 */
 };
 
+
+/**
+ * Free operation structure
+ * If operation has been allocate from a rte_mempool, then the operation will
+ * be returned to the mempool.
+ *
+ * @param op
+ *   Compress operation pointer allocated from rte_comp_op_alloc()
+ *   If op is NULL, no operation is performed.
+ */
+void
+rte_comp_op_free(struct rte_comp_op *op);
+
 /**
  * Creates an operation pool
  *
@@ -501,7 +514,8 @@ struct __rte_cache_aligned rte_comp_op {
 struct rte_mempool *
 rte_comp_op_pool_create(const char *name,
 		unsigned int nb_elts, unsigned int cache_size,
-		uint16_t user_size, int socket_id);
+		uint16_t user_size, int socket_id)
+	__rte_malloc __rte_dealloc(rte_comp_op_free, 1);
 
 /**
  * Allocate an operation from a mempool with default parameters set
@@ -533,18 +547,6 @@ int
 rte_comp_op_bulk_alloc(struct rte_mempool *mempool,
 		struct rte_comp_op **ops, uint16_t nb_ops);
 
-/**
- * Free operation structure
- * If operation has been allocate from a rte_mempool, then the operation will
- * be returned to the mempool.
- *
- * @param op
- *   Compress operation pointer allocated from rte_comp_op_alloc()
- *   If op is NULL, no operation is performed.
- */
-void
-rte_comp_op_free(struct rte_comp_op *op);
-
 /**
  * Bulk free operation structures
  * If operations have been allocated from an rte_mempool, then the operations
-- 
2.45.2