From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id B6C721B116; Tue, 23 Oct 2018 18:25:01 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 75F722212C; Tue, 23 Oct 2018 12:24:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 23 Oct 2018 12:24:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=mesmtp; bh=EtfRF/hP2P4BUWM1wnIjheK 0OCxfYtJ2R8T1Dzw6JIQ=; b=XjorcoUZGVZW8AdTZuihY34stAcUB9pLivPL87y s1JzJyrWy22Wl55kSjvikDas7nWIm/gR2nvRv8B0pPmvD1RJj52zKtXmT8w1XyjX yOJVM9e0m0/4KNN7QXtUErJ/o7pys19oD9Ra9mzxZ0+dqoOpqnIwpSnreXb3i8PG DWvE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=EtfRF/hP2P4BUWM1w nIjheK0OCxfYtJ2R8T1Dzw6JIQ=; b=OL51tU/MBbY7Iw+oimJFWuaQNUrm7zxaV iIzcNnZiQiILqlVucterPFKEl2Qpq667qGj9ph44kcBxYvaEaHuumDB3/gjCbBud FIQioQqcOb5OwDniF9lINsVPClO4BnKv2EssgW+OeoKStFdHwuyNT2TX1nBnldjc zFcFqkVh1lmDZ5EhY0mO5emt641ed9d2lPe79l3PDpD6IP1nOY7DMHcnADyt/wYz FPqp5qDL7l7bGWwZh1W17z5rfmcY3wK7EygoZ08Z97BRRRxFX14pG0EwbUQ91Nms H03/NOzlNOso4SeZhLKzoHIoHvFPV0mdQEsthOERBuJh4KqeQGnQw== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 6163D102A0; Tue, 23 Oct 2018 12:24:58 -0400 (EDT) From: Thomas Monjalon To: olivier.matz@6wind.com Cc: dev@dpdk.org, stable@dpdk.org Date: Tue, 23 Oct 2018 18:24:54 +0200 Message-Id: <20181023162454.15519-1-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH] kvargs: fix processing a null list X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Oct 2018 16:25:02 -0000 In the doxygen description of rte_kvargs_process(), it is said: If *kvlist* is NULL function does nothing. It has been added by mistake here instead of rte_kvargs_free(). Anyway, null list should be correctly handled in both functions. Comments are fixed in both functions and NULL handling is added to rte_kvargs_process(). Fixes: c34af7424e09 ("kvargs: fix freeing behaviour for null") Cc: stable@dpdk.org Signed-off-by: Thomas Monjalon --- lib/librte_kvargs/rte_kvargs.c | 3 +++ lib/librte_kvargs/rte_kvargs.h | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c index 427bfd5e5..f371bc5a0 100644 --- a/lib/librte_kvargs/rte_kvargs.c +++ b/lib/librte_kvargs/rte_kvargs.c @@ -138,6 +138,9 @@ rte_kvargs_process(const struct rte_kvargs *kvlist, bool match = false; unsigned i; + if (kvlist == NULL) + return 0; + for (i = 0; i < kvlist->count; i++) { pair = &kvlist->pairs[i]; if (key_match == NULL || strcmp(pair->key, key_match) == 0) { diff --git a/lib/librte_kvargs/rte_kvargs.h b/lib/librte_kvargs/rte_kvargs.h index c7378b4e9..c7a97a8eb 100644 --- a/lib/librte_kvargs/rte_kvargs.h +++ b/lib/librte_kvargs/rte_kvargs.h @@ -110,7 +110,7 @@ struct rte_kvargs *rte_kvargs_parse_delim(const char *args, * rte_kvargs_parse(). * * @param kvlist - * The rte_kvargs structure + * The rte_kvargs structure. No error if NULL. */ void rte_kvargs_free(struct rte_kvargs *kvlist); @@ -119,11 +119,10 @@ void rte_kvargs_free(struct rte_kvargs *kvlist); * * For each key/value association that matches the given key, calls the * handler function with the for a given arg_name passing the value on the - * dictionary for that key and a given extra argument. If *kvlist* is NULL - * function does nothing. + * dictionary for that key and a given extra argument. * * @param kvlist - * The rte_kvargs structure + * The rte_kvargs structure. No error if NULL. * @param key_match * The key on which the handler should be called, or NULL to process handler * on all associations -- 2.19.0