From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 25B9D45A50;
	Sat, 28 Sep 2024 18:49:54 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id D174B40A76;
	Sat, 28 Sep 2024 18:48:50 +0200 (CEST)
Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com
 [209.85.214.173])
 by mails.dpdk.org (Postfix) with ESMTP id 8E2B840657
 for <dev@dpdk.org>; Sat, 28 Sep 2024 18:48:39 +0200 (CEST)
Received: by mail-pl1-f173.google.com with SMTP id
 d9443c01a7336-206b9455460so23379015ad.0
 for <dev@dpdk.org>; Sat, 28 Sep 2024 09:48:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542119;
 x=1728146919; 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=XsAhH0ZX3ddPj6j1bm6B9FX9Jp/gzrG8giI4aV5Q6Us=;
 b=oy2gX4AQGp3dE/5/vvLahAWWcUnXctpR1y2WUPi+YlYw5Auq9jOmJOP/dP6S81272n
 Z0xeRWbiIb4ZfZgU1OADTjX6+STwAYamOceW5bmDtcIxM+B+G6kOL4zxYBel6jvql4xx
 /DcXGxYETYInaMbRPitTeWi3ILr58q1R0YN7guw5StyDFlp/O7wh4y/EYU9on+C/wyu9
 7IkuwSgPp/up7nY8MzExX1OEXJsgjFX3/SqTs/drTBa6k3FeuDNdBvCpQTHx+BHKGxC/
 Fspt9GpEbZpj8H6SUZry2SQ5CWumjo3EWWPcSlY3ehSd2WeztXz70qPlhairGTgJxMCY
 Zanw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1727542119; x=1728146919;
 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=XsAhH0ZX3ddPj6j1bm6B9FX9Jp/gzrG8giI4aV5Q6Us=;
 b=eW959IBKuOVHrEVD77m0T3FS7VjV1coKdBQwiUUKK+ipkaVOef5TqLqiQIYxiHvxQ/
 QMXAhI52hSQD+CWCQLaZEQanUpLVuU8+mFxKTdgGzgb6LSnMqayMHpRMmRQvPdDHZ62v
 DlUNzR1Lf5DGdCkrXwsUCUZjvjO7ewHdunks1MEA5/s/mcbTtvyUTH5Hjaz56VLC2TzJ
 NRqEaE8Nf0IuSv18nVKAPplhgvPZRdoHiZ06Mii3n2KaiLQoJgse5jFoGKJoHAWhfBpw
 ByUetV6FHkrSmeWiLwr4Zt0FB6pQRi2kPqw+eD6thyoBVapUpdD4Q6ErHC6DtRO7DhHq
 K+Ew==
X-Gm-Message-State: AOJu0YyWaPXlusgxRPK1I1PDFhYVp3V0wi/emoSq5Hr7DVXXqHxOJK7b
 jHwvm4fpVoWyYld3lURs2pPFi5hZwyVwdkCLxFhfHNsLJFUT/1foptnO0HLEB5P5qIju4rLShN4
 6
X-Google-Smtp-Source: AGHT+IFkTqzJNipSI9slbdLR5DnmMUSg9IQ7G52CHU9qeqUNr/E+diW/GwfnDq50Loq0xYQ8yo8PNg==
X-Received: by 2002:a17:902:d486:b0:206:aa47:adc0 with SMTP id
 d9443c01a7336-20b19cb8b17mr165219575ad.24.1727542118710; 
 Sat, 28 Sep 2024 09:48:38 -0700 (PDT)
Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-20b37e47c7dsm28854015ad.216.2024.09.28.09.48.38
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 28 Sep 2024 09:48:38 -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 v2 15/16] drivers/ifpga: fix free function mismatch
Date: Sat, 28 Sep 2024 09:47:23 -0700
Message-ID: <20240928164814.861933-16-stephen@networkplumber.org>
X-Mailer: git-send-email 2.45.2
In-Reply-To: <20240928164814.861933-1-stephen@networkplumber.org>
References: <20240927204742.546164-1-stephen@networkplumber.org>
 <20240928164814.861933-1-stephen@networkplumber.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-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 a972b3b7a4..86558c7b9b 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\n", name);
 
-	free(intr_efds);
+	rte_free(intr_efds);
 	return 0;
 }
 
-- 
2.45.2