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 044DC45A50; Sat, 28 Sep 2024 18:49:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF3FE40673; Sat, 28 Sep 2024 18:48:40 +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 29E8E4060A for ; Sat, 28 Sep 2024 18:48:33 +0200 (CEST) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2068acc8b98so33838805ad.3 for ; Sat, 28 Sep 2024 09:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542112; x=1728146912; 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=PmRTbddZLG2JxQ2OFMT3a37iU/8U3GJd/GKLMFfTKa0=; b=0O/HMTwbAH+2T5UdCiT8AajGM6Ezc1LM2gU9ewljWjmNXJ6WLEORxTB1vEFd2HLRvp 4JtoHw3hR8O2Pib/WHDp1SeXT+jxr24hj79XVrtkgxZWeKgNDL/PpW/2mM78tYO/C63u 8n3Hg2SspQq74gdH/ztNbBU2CffgzYpLInkK8R4MCzdjhjlIkkgsIxTQPfbIxG81TAv7 6U+cczTKov9fY6jbZzwRDQy77UYrT4WzhULiJalOpoIK4QlSN6B+apjcpPLAUNcO5Muw +A1hoz89tJGwXToVPRHRPUtvF7xVvADlVE+HxBSERFtyN53AqAevQX+Es1N+9yJXJ0hV mNzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542112; x=1728146912; 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=PmRTbddZLG2JxQ2OFMT3a37iU/8U3GJd/GKLMFfTKa0=; b=HwCo8YHW5Ru0BZx3Ej/QrJO2DBvuFLYclt2zhi/9tpwZGozvNmHiQpYRIczB5z69x/ /6QRcVEyjc9bmq4mX+aSL35tjI0vb+VyHTcWmjchVOEYIqBzEDJ8bKAl25SDItGJlouh TXwuatSdfqH+LcIxMA8ePhHDLEOvnJcZ1W4HqCuxlgyLW94/DytQF+lGygNx7z26NsNG sIuyFfpFP8+KPDc+m5+CT0ltE0kSadMPUc829K7f7einIKRW/TzNaL20WS2yJmsWWkDq 6+gz6UNiqcq6K/aLgWppFA9lr/Ydqa3B2ULm/w/4+fB9x7ozrU8NhSpdQYOcNbBLvt60 PDhw== X-Gm-Message-State: AOJu0YyLKl9QqnxoQ/rZALXJyU6CYX16DzyfB10qYR0zu/7qZcxkWMBE L3o3ibz3XvwYMu0EHx6+9574+l5CXrb5xmw9LAZctwE61aa8aydMQk4aSjEjqUv0lqZmi/wztoW j X-Google-Smtp-Source: AGHT+IGBx8QM/QJG+RSKmzGZHlTOcpyBtyv+9n6JZWcDoHw1sfW4BACkPFFrgwlwNP/MDXdxXwIs4g== X-Received: by 2002:a17:902:d2d2:b0:205:8a25:904b with SMTP id d9443c01a7336-20b37bcf765mr104068755ad.57.1727542112289; Sat, 28 Sep 2024 09:48:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:31 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Konstantin Ananyev , Ray Kinsella Subject: [PATCH v2 08/16] bpf: fix free mismatch if convert fails Date: Sat, 28 Sep 2024 09:47:16 -0700 Message-ID: <20240928164814.861933-9-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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 If conversion of cBF to eBPF fails then an object allocated with rte_malloc() would be passed to free(). [908/3201] Compiling C object lib/librte_bpf.a.p/bpf_bpf_convert.c.o ../lib/bpf/bpf_convert.c: In function ‘rte_bpf_convert’: ../lib/bpf/bpf_convert.c:559:17: warning: ‘free’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc] 559 | free(prm); | ^~~~~~~~~ ../lib/bpf/bpf_convert.c:545:15: note: returned from ‘rte_zmalloc’ 545 | prm = rte_zmalloc("bpf_filter", | ^~~~~~~~~~~~~~~~~~~~~~~~~ 546 | sizeof(*prm) + ebpf_len * sizeof(*ebpf), 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: 2eccf6afbea9 ("bpf: add function to convert classic BPF to DPDK BPF") Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- lib/bpf/bpf_convert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bpf/bpf_convert.c b/lib/bpf/bpf_convert.c index d7ff2b4325..e7e298c9cb 100644 --- a/lib/bpf/bpf_convert.c +++ b/lib/bpf/bpf_convert.c @@ -556,7 +556,7 @@ rte_bpf_convert(const struct bpf_program *prog) ret = bpf_convert_filter(prog->bf_insns, prog->bf_len, ebpf, &ebpf_len); if (ret < 0) { RTE_BPF_LOG_LINE(ERR, "%s: cannot convert cBPF to eBPF", __func__); - free(prm); + rte_free(prm); rte_errno = -ret; return NULL; } -- 2.45.2