From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 6519E45AE3
	for <public@inbox.dpdk.org>; Tue,  8 Oct 2024 18:49:26 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 37AE4410FC;
	Tue,  8 Oct 2024 18:49:18 +0200 (CEST)
Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com
 [209.85.215.169])
 by mails.dpdk.org (Postfix) with ESMTP id 717D040E4D
 for <stable@dpdk.org>; Tue,  8 Oct 2024 18:49:06 +0200 (CEST)
Received: by mail-pg1-f169.google.com with SMTP id
 41be03b00d2f7-7db908c9c83so3720673a12.2
 for <stable@dpdk.org>; Tue, 08 Oct 2024 09:49:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1728406145;
 x=1729010945; 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=jufL1Xx6Vcy1vUxL0AdrUCYAgWJlHW3xe3BF1P60Ueg=;
 b=nseGiUjOM7EWXwHI/EmEXglvcKZufNYem7yRNL6lbzq3hb0MrzD8VsQ/Z70rgKSVPP
 EW4+WA/CG1bAVSTs7tTxNGWFpftxJFoqxGluD+tDfiWCRVpB1ypQ750g5Wb4pgCdccFH
 OB3Ip2NkiD2FFBxp/p9b9O5sppq7zs7YdvtSRkjbpdWVGf4QE+x+ceQIWlr1vySSLsXS
 BEQJ/QjZ7sN1hq5yb4jvnfPa22xFEhJmcpWF3edmFGkvtnntOSlW1uPu+ftmIQkqwIIe
 fw2kDZdC1ndye8cwv2CZ2wLT9W30uT3Zn4s29VWmsldRyQTrnTt53a2doGTU9VXzIPkJ
 YxTA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1728406145; x=1729010945;
 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=jufL1Xx6Vcy1vUxL0AdrUCYAgWJlHW3xe3BF1P60Ueg=;
 b=YVsoMO44QSHehqZ7WFNZEh8q6LChRlXDMwN1mtRUBAQAymGkdOH14+0eWiyQunrnyu
 Bcotvuu3q7y4RefKsuerpJLnGJLhnrNwrPoy6pftPnelww1HkAvgwjYvWhYsdwFdiz7v
 EY6h48xXvm5MBfqcYXf0YfdnoaSdPEP29E1ygAD3UJHy9ZfHZmA3FOWHKNdEidl2kaWh
 sTuSfO2itYbcU1ZOhj2dj6Mp65dLh6xnjG2LN8QQkPDAM4NLdAMe7ATi+VEaA//R5CUL
 pQ6eKBO4uFgD+I9k8HSPKNvsOQ+jrQxutZYBe5YnfU0FbPBfY7XPUM+1G2YlRVk1THWc
 4BFA==
X-Forwarded-Encrypted: i=1;
 AJvYcCUkO9POk0RgQn92hMg6E50TjhditWyD5OIW5/umknv6QVB5OJcq32d/1ln9v4T09MnAf0idx/s=@dpdk.org
X-Gm-Message-State: AOJu0YwflxtojRuRyIjd4OGwcNwg4mYUzGJUUByVvuoOCoM+mBDm38ft
 Vr6dM7SSky6uU762wWs+xjv7R9GO9QMdasCnrRwKpxGXiA1jOIRkULRABo4ZFqk=
X-Google-Smtp-Source: AGHT+IH1snEXIT5FTJwl7c5FDpY1k3JoCvT6Vvw2Be1WScerGXroH84WRoaZyQHOn3eczXPFnhvqgA==
X-Received: by 2002:a17:902:db03:b0:20b:530f:e202 with SMTP id
 d9443c01a7336-20bfe023d6dmr239113625ad.1.1728406145601; 
 Tue, 08 Oct 2024 09:49:05 -0700 (PDT)
Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-20c54056bd9sm13832965ad.85.2024.10.08.09.49.04
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 08 Oct 2024 09:49:05 -0700 (PDT)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>, hkalra@marvell.com,
 stable@dpdk.org, Rosen Xu <rosen.xu@intel.com>,
 Hyong Youb Kim <hyonkim@cisco.com>,
 David Marchand <david.marchand@redhat.com>
Subject: [PATCH v9 14/17] drivers/ifpga: fix free function mismatch
Date: Tue,  8 Oct 2024 09:47:18 -0700
Message-ID: <20241008164842.139045-15-stephen@networkplumber.org>
X-Mailer: git-send-email 2.45.2
In-Reply-To: <20241008164842.139045-1-stephen@networkplumber.org>
References: <20240927204742.546164-1-stephen@networkplumber.org>
 <20241008164842.139045-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 <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org

The raw ifpga driver redefines malloc to be opae_malloc
and free to be opae_free; which is a bad idea.

This leads to case where interrupt efd array is allocated
with calloc() and then passed to rte_free. The workaround
is to allocate the array with rte_calloc() instead.

Fixes: d61138d4f0e2 ("drivers: remove direct access to interrupt handle")
Cc: hkalra@marvell.com
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/raw/ifpga/ifpga_rawdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index 113a22b0a7..5b9b596435 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -1499,7 +1499,7 @@ ifpga_register_msix_irq(struct ifpga_rawdev *dev, int port_id,
 
 		nb_intr = rte_intr_nb_intr_get(*intr_handle);
 
-		intr_efds = calloc(nb_intr, sizeof(int));
+		intr_efds = rte_calloc("ifpga_efds", nb_intr, sizeof(int), 0);
 		if (!intr_efds)
 			return -ENOMEM;
 
@@ -1508,7 +1508,7 @@ ifpga_register_msix_irq(struct ifpga_rawdev *dev, int port_id,
 
 		ret = opae_acc_set_irq(acc, vec_start, count, intr_efds);
 		if (ret) {
-			free(intr_efds);
+			rte_free(intr_efds);
 			return -EINVAL;
 		}
 	}
@@ -1517,13 +1517,13 @@ ifpga_register_msix_irq(struct ifpga_rawdev *dev, int port_id,
 	ret = rte_intr_callback_register(*intr_handle,
 			handler, (void *)arg);
 	if (ret) {
-		free(intr_efds);
+		rte_free(intr_efds);
 		return -EINVAL;
 	}
 
 	IFPGA_RAWDEV_PMD_INFO("success register %s interrupt", name);
 
-	free(intr_efds);
+	rte_free(intr_efds);
 	return 0;
 }
 
-- 
2.45.2