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 55F8EA00C2 for ; Sun, 5 Jun 2022 09:52:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 42ACF42B79; Sun, 5 Jun 2022 09:52:18 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 43C71410EA; Wed, 1 Jun 2022 12:55:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654080914; x=1685616914; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vE957rAt9OW00McYjIZBghY0LaPcu29mg/RAXgPaTuw=; b=Ey0cgJeIzIrcqdCPcLB87qfHccFC71+zM4OvtEkOHTBGXTq00w2lcFbp iTgUj3Rh7KPivkWzVIsv6dr8NQ8DbvnnczLGZERBraI214zSNN4rb8ECK /r8UbX/OVfTqx22GZJ6+7BfkyBs03SOSp9TESlXfBKysBm0lNvKIKFL1Y F1fIVgvzMFh5433HFcjUIKWCYiOdH1HQR2sijxK9nScWxeobZVslzsGor Lr6+8RPHm71gUw9yQmiwAfHtGAQKZDLcQumw1ap7GQeuRIhG56fjZEC+I 0f41Al2TfmcvYhj/8hXCorrQF6em9Y4oVekHBQrmZOKBzEo+RvjF8uDHw w==; X-IronPort-AV: E=McAfee;i="6400,9594,10364"; a="275557241" X-IronPort-AV: E=Sophos;i="5.91,268,1647327600"; d="scan'208";a="275557241" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2022 03:55:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,268,1647327600"; d="scan'208";a="755862804" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.52]) by orsmga005.jf.intel.com with ESMTP; 01 Jun 2022 03:55:12 -0700 From: Hamza Khan To: David Hunt , Alan Carew , Pablo de Lara Cc: dev@dpdk.org, Hamza Khan , stable@dpdk.org Subject: [PATCH 2/2] examples/vm_power_manager: use safe version of list iterator Date: Wed, 1 Jun 2022 10:54:55 +0000 Message-Id: <20220601105455.166505-2-hamza.khan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220601105455.166505-1-hamza.khan@intel.com> References: <20220601105455.166505-1-hamza.khan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Sun, 05 Jun 2022 09:52:16 +0200 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 Currently, when vm_power_manager exits, we are using a LIST_FOREACH macro to iterate over VM info structures while freeing them. This leads to use-after-free error. To address this, use the newly added LIST_FOREACH_SAFE macro. Fixes: e8ae9b662506 ("examples/vm_power: channel manager and monitor in host") Cc: alan.carew@intel.com Cc: stable@dpdk.org Signed-off-by: Hamza Khan --- examples/vm_power_manager/channel_manager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c index 838465ab4b..bc95cec8d6 100644 --- a/examples/vm_power_manager/channel_manager.c +++ b/examples/vm_power_manager/channel_manager.c @@ -1005,9 +1005,9 @@ channel_manager_exit(void) { unsigned i; char mask[RTE_MAX_LCORE]; - struct virtual_machine_info *vm_info; + struct virtual_machine_info *vm_info, *tmp; - LIST_FOREACH(vm_info, &vm_list_head, vms_info) { + LIST_FOREACH_SAFE(vm_info, &vm_list_head, vms_info, tmp) { rte_spinlock_lock(&(vm_info->config_spinlock)); -- 2.25.1