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 A3D06460C5 for ; Mon, 20 Jan 2025 13:22:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 96DEE40E1D; Mon, 20 Jan 2025 13:22:23 +0100 (CET) Received: from mail-lf1-f97.google.com (mail-lf1-f97.google.com [209.85.167.97]) by mails.dpdk.org (Postfix) with ESMTP id 5F88D40E1D for ; Mon, 20 Jan 2025 13:22:22 +0100 (CET) Received: by mail-lf1-f97.google.com with SMTP id 2adb3069b0e04-53e3a37ae07so4639536e87.3 for ; Mon, 20 Jan 2025 04:22:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; t=1737375742; x=1737980542; 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=13N10RDYO8V5/P7fWWf1cwtghuSGAEEa145FMHTIz3o=; b=GkjIvcvwaW/cUz54dOaQ4zjdlyEs5oPrhornwzGxp2lYhaK/Cue+Rx/qfB3DlYa8Pk NynLBpVWNET4ab8DoxEo0FtILzQhOGb9lEZOkuCfeO6KvEIb6oJelkBHI2OQnoQBAJO0 iXfJfBXR5O6QKhttgyoqB0g1Bsym2Bdlszcaa8QfVjVi3ESgG2eFm7AxT2Ld8BxHIAlR ywQImXDTMUlkW3mbXhdpuUbkzZELIfGdskG/O9xoxx7t/dDNsH0kdrW7uEbMrUi6CV6D m4gB/0nI0ZEreT+UqFxGU/FuBDD9aFHOBN+a4iKAc+l0Ql6ajw3zZkj83Y1QB0s8VIlL NAzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737375742; x=1737980542; 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=13N10RDYO8V5/P7fWWf1cwtghuSGAEEa145FMHTIz3o=; b=T0fgHaytXmsfS+eu+7Zdc00sPWEQkOcxFfP8FoBHzGMNC/gtKCD/seHhKDpg4MX9Gv hYjCW5kLQJZY3cHCdqBwpUOejRl0LJvQ1P7xGwij9Rn/AUsTExP4waYMKnUG06Em6Bw4 xwxQTBj9NQozdOgBJ0Ga8pfj6MmGgeytlqYgy5Kmx/qlnvUqLqMUzByiGkOraYjN5W6X 6rzeIGfPsql70xITFBRJIz2Pq3W5TN7yIJnWe1ksvLJj3DfqhDkoLWEmGLGaj5E2S755 ucELI2VG6ir2Gmi4bdfayzTPmt69liVrDzeQJR9qiWxI8CiJ9UU99qYYvjFQBlnrWU1x XiuQ== X-Gm-Message-State: AOJu0YwU104GULTvMzvYNfmJhbqgj+CI5zmJ3FOfIYxPYwID9kiMIj2f W4rGJLNerf45Wsw05zB7vO8dVIqYBHfJcTXr8EVAW0CHDyE9aal9R/IyjNdddh5jqz2mHofmu+d +GxjC3lh92QxT2hNg0ep+Fopi2MUfQ90y X-Gm-Gg: ASbGnctHmBZXEHW6hXLRj4GrJXUrJGQ47YcMldEmZj7QzrlknkRAvHxeNy+7dJ+l2zQ kUS8c53nQkoEql+JtShmDajke8JLLoqWBNOECJKIlABeCgw0tqDs8k7jjiGcneMRymZZ4eH4kMM zYhdcw25bKyGbvZVnx4foZ12kNOUYT4Q+LRat3SUIHaLKpftFSKIxJ0ZvvQXD7gveyTGzx3m8c+ SpKTR+ATypvpVZmunovcsZsGCFrzGK7xZbJUY0SOsdi/BzhoZuQTi2CMfDGIkqbWyfBRWFIn9ja OfDql81QQ0zAb/H6lHp3OwEi0s+dfxxTQ1TotSg= X-Google-Smtp-Source: AGHT+IG9KEJ+sVO8TsSGe7+T35E8TTZZ8MDTzmt/CugxkkiLPlD52gZkFlIumVEqtPfZqXISv1kP/Ckvgc5n X-Received: by 2002:ac2:42c1:0:b0:542:7196:d1ed with SMTP id 2adb3069b0e04-5439c2807d8mr3320850e87.53.1737375741789; Mon, 20 Jan 2025 04:22:21 -0800 (PST) Received: from smtpservice.6wind.com ([185.13.181.2]) by smtp-relay.gmail.com with ESMTP id 2adb3069b0e04-5439af5fbbdsm240637e87.92.2025.01.20.04.22.21; Mon, 20 Jan 2025 04:22:21 -0800 (PST) X-Relaying-Domain: 6wind.com Received: from localhost (rainbow.dev.6wind.com [10.17.1.165]) by smtpservice.6wind.com (Postfix) with ESMTP id 66E2C138E8; Mon, 20 Jan 2025 13:22:21 +0100 (CET) From: Ariel Otilibili To: dev@dpdk.org Cc: stable@dpdk.org, Thomas Monjalon , David Marchand , Ariel Otilibili , Andrew Rybchenko , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Konstantin Ananyev Subject: [PATCH v2 2/2] mempool: make rte_mempool_create_empty a single-exit Date: Mon, 20 Jan 2025 13:21:56 +0100 Message-Id: <20250120122156.2480524-3-ariel.otilibili@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250120122156.2480524-1-ariel.otilibili@6wind.com> References: <20250119174643.2162110-1-ariel.otilibili@6wind.com> <20250120122156.2480524-1-ariel.otilibili@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org For properly setting rte_errno, and exiting rte_mempool_create_empty() from a single place. Bugzilla ID: 1559 Signed-off-by: Ariel Otilibili --- lib/mempool/rte_mempool.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c index 1e4f24783c0b..3f9a4a1771d3 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -831,20 +831,20 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, /* asked for zero items */ if (n == 0) { rte_errno = EINVAL; - return NULL; + goto exit; } /* asked cache too big */ if (cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE || CALC_CACHE_FLUSHTHRESH(cache_size) > n) { rte_errno = EINVAL; - return NULL; + goto exit; } /* enforce only user flags are passed by the application */ if ((flags & ~RTE_MEMPOOL_VALID_USER_FLAGS) != 0) { rte_errno = EINVAL; - return NULL; + goto exit; } /* @@ -860,7 +860,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, /* calculate mempool object sizes. */ if (!rte_mempool_calc_obj_size(elt_size, flags, &objsz)) { rte_errno = EINVAL; - return NULL; + goto exit; } rte_mcfg_mempool_write_lock(); @@ -877,7 +877,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, te = rte_zmalloc("MEMPOOL_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { RTE_MEMPOOL_LOG(ERR, "Cannot allocate tailq entry!"); - goto exit_unlock; + goto unlock; } mempool_size = RTE_MEMPOOL_HEADER_SIZE(mp, cache_size); @@ -887,12 +887,12 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, ret = snprintf(mz_name, sizeof(mz_name), RTE_MEMPOOL_MZ_FORMAT, name); if (ret < 0 || ret >= (int)sizeof(mz_name)) { rte_errno = ENAMETOOLONG; - goto exit_unlock; + goto unlock; } mz = rte_memzone_reserve(mz_name, mempool_size, socket_id, mz_flags); if (mz == NULL) - goto exit_unlock; + goto unlock; /* init the mempool structure */ mp = mz->addr; @@ -900,7 +900,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, ret = strlcpy(mp->name, name, sizeof(mp->name)); if (ret < 0 || ret >= (int)sizeof(mp->name)) { rte_errno = ENAMETOOLONG; - goto exit_unlock; + goto unlock; } mp->mz = mz; mp->size = n; @@ -930,7 +930,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, if (ret) { rte_errno = -ret; - goto exit_unlock; + goto unlock; } /* @@ -956,13 +956,16 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, rte_mempool_trace_create_empty(name, n, elt_size, cache_size, private_data_size, flags, mp); - return mp; + goto exit; -exit_unlock: +unlock: rte_mcfg_mempool_write_unlock(); rte_free(te); rte_mempool_free(mp); - return NULL; + mp = NULL; + +exit: + return mp; } /* create the mempool */ -- 2.30.2 <