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 B5FD0A0A02; Wed, 5 May 2021 17:22:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 39F1040143; Wed, 5 May 2021 17:22:58 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 7687240040; Wed, 5 May 2021 17:22:56 +0200 (CEST) IronPort-SDR: Cl5yPwS5s8n0lT/1+rz1RGnJ2f87DXFW7fNXqVRNd3am7y2lefq8HOndfjFk673fCsyDONGzvX 6dDbIiyb/H2Q== X-IronPort-AV: E=McAfee;i="6200,9189,9975"; a="219089449" X-IronPort-AV: E=Sophos;i="5.82,275,1613462400"; d="scan'208";a="219089449" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2021 08:22:55 -0700 IronPort-SDR: V95/Hi6N+aKM3FIer3FVCXe6dXSFgeuU15AvB5Pz1u04u8VbvIovkcIZ/lw9jOo9tzfXt1PXqL uPE/sMCxFfhg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,275,1613462400"; d="scan'208";a="406587759" Received: from silpixa00400355.ir.intel.com (HELO silpixa00400355.ger.corp.intel.com) ([10.237.223.148]) by orsmga002.jf.intel.com with ESMTP; 05 May 2021 08:22:53 -0700 From: Ciara Power To: dev@dpdk.org Cc: stable@dpdk.org, bruce.richardson@intel.com, Ciara Power , David Marchand Date: Wed, 5 May 2021 15:22:48 +0000 Message-Id: <20210505152248.253496-1-ciara.power@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] telemetry: fix accessing callbacks list using lock 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 Sender: "dev" The list_commands() function accessed the callbacks list, but did not take the lock. This may have caused inconsistencies if callbacks were being registered at the same time. This is now fixed to lock before iterating the list, and unlock afterwards. Fixes: f38748736eb2 ("telemetry: add default callback commands") Cc: stable@dpdk.org Signed-off-by: Ciara Power Reported-by: David Marchand --- lib/telemetry/telemetry.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 386d0080bc..68b479e0e4 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -104,8 +104,10 @@ list_commands(const char *cmd __rte_unused, const char *params __rte_unused, int i; rte_tel_data_start_array(d, RTE_TEL_STRING_VAL); + rte_spinlock_lock(&callback_sl); for (i = 0; i < num_callbacks; i++) rte_tel_data_add_array_string(d, callbacks[i].cmd); + rte_spinlock_unlock(&callback_sl); return 0; } -- 2.25.1