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 4C7C445A48 for ; Fri, 27 Sep 2024 22:48:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2B3A940A81; Fri, 27 Sep 2024 22:48:19 +0200 (CEST) Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by mails.dpdk.org (Postfix) with ESMTP id 827E240667 for ; Fri, 27 Sep 2024 22:48:08 +0200 (CEST) Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-7e6ed072cdaso49918a12.0 for ; Fri, 27 Sep 2024 13:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727470087; x=1728074887; 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=06J0UyE8Dnp7ti3PueEoXg75lBUxlkSP8fL1kmtEqoE=; b=PwLEdvNi+3F8hhDMvvspm5TlxwnsP2Slq3EBb+f1ZMpicg/kzN0gJ/oNicPFZbnAGG aUdm63Cjmz69DY7m1VWgsI6J3mGv1CkjvTSTfxbBShiO8em/F70bSjkQ21/5K3v1oH3o 7fMsX7j5td0nIb59R4ixd1SbQ68ktAGNmZY289XqAhwO8lgl20ACwUVzQz9vTcvGoluZ Is7THmbjXK9yfg3uozcVhwxYCazdmAW0TNlvapzMZV7N/Qk9bCozOS2bHyuT6kv2RKd+ s4YunFQz+M29qyDEpa6NaLW6OsxWXrVxh7Qw1PNIF7GI4pBuu/lOdnTsHLUlUOumYwu6 SVhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727470087; x=1728074887; 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=06J0UyE8Dnp7ti3PueEoXg75lBUxlkSP8fL1kmtEqoE=; b=IBXreQYB3qSRAid76DDhHVp39NOGqBZ4DbTWHRebrwIHcQBzschdZXIeGNd2LDLx1B VY1yH8PLI1T7NR7NJrp0JZN/g+NIKtopBoRB1fBSoHVYV7dqJPTjba1+eD1LHKaLM2/f RUTUGabiy/+/px0Wwwyv2X3JiUye9+s7tuDseXA1/GqScGsxNnpVHqX03fq0b8AZvhtL /IcAhDg8NgyB2cG5Xqt1yZ+f84I1BeesCHR1qIWNzkhASVVgDQ4V/O0+ihzWteR+KUnA i4ohSMj8cGVx47nf2N05wOsaUAQ+GiaD3XpGs2fn4fGHpMVY9TZC4M/vcrmL+1ZHF+gQ TBKA== X-Forwarded-Encrypted: i=1; AJvYcCVudNThW7sBSgCSd0W7LZxigBgiQn8mfdIb1w6BlcTaGmRX9Lt9Mlbza7GECQW75s1L01crfIw=@dpdk.org X-Gm-Message-State: AOJu0YwAnjlBSSKaQ5/slsb3SBkME1Rm2+bDZL3ajHZp+vSHcaJDD1LL VREp+2Mkz3g1/AKtUAi/wPUDn4x397DmEqzdW1BjxwuB/lvgLCKKuCE8jEbTKvo= X-Google-Smtp-Source: AGHT+IH5zzZxRhWvgSdadENHzoc6RNLfUH4nz9En4u27+UVrV9v+ZzwJPrmRg4zMnCNmcyiKbgvc/Q== X-Received: by 2002:a05:6a20:c704:b0:1cf:2988:c34c with SMTP id adf61e73a8af0-1d4fa6c77ecmr6635767637.22.1727470087706; Fri, 27 Sep 2024 13:48:07 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6db294533sm2036531a12.12.2024.09.27.13.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:48:07 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , tianfei.zhang@intel.com, stable@dpdk.org, Rosen Xu , Andy Pei Subject: [PATCH 12/16] raw/ifpga/base: fix use after free Date: Fri, 27 Sep 2024 13:45:48 -0700 Message-ID: <20240927204742.546164-13-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927204742.546164-1-stephen@networkplumber.org> References: <20240927204742.546164-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The TAILQ_FOREACH() macro would refer to info after it had been freed. Fix by introducing TAILQ_FOREACH_SAFE here. Fixes: 4a19f89104f8 ("raw/ifpga/base: support multiple cards") Cc: tianfei.zhang@intel.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/raw/ifpga/base/opae_intel_max10.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c b/drivers/raw/ifpga/base/opae_intel_max10.c index dd97a5f9fd..d5a9ceb6e3 100644 --- a/drivers/raw/ifpga/base/opae_intel_max10.c +++ b/drivers/raw/ifpga/base/opae_intel_max10.c @@ -6,6 +6,13 @@ #include #include "opae_osdep.h" +#ifndef TAILQ_FOREACH_SAFE +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = TAILQ_FIRST((head)); \ + (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif + int max10_sys_read(struct intel_max10_device *dev, unsigned int offset, unsigned int *val) { @@ -746,9 +753,9 @@ static int fdt_get_named_reg(const void *fdt, int node, const char *name, static void max10_sensor_uinit(struct intel_max10_device *dev) { - struct opae_sensor_info *info; + struct opae_sensor_info *info, *next; - TAILQ_FOREACH(info, &dev->opae_sensor_list, node) { + TAILQ_FOREACH_SAFE(info, &dev->opae_sensor_list, node, next) { TAILQ_REMOVE(&dev->opae_sensor_list, info, node); opae_free(info); } -- 2.45.2