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 19BA845A9F; Wed, 2 Oct 2024 20:40:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2B3BA4069D; Wed, 2 Oct 2024 20:39:41 +0200 (CEST) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by mails.dpdk.org (Postfix) with ESMTP id 139E04065C for ; Wed, 2 Oct 2024 20:39:35 +0200 (CEST) Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-7ae3d7222d4so39323a12.3 for ; Wed, 02 Oct 2024 11:39:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727894374; x=1728499174; 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=FPcpPv/bXrQN7oNHRVBvMXGbxw5y7whpxgz8iRZs+dMO2mU/Si/n4Bq+a6RU4ekN9m hM+mAjDySa/vPiD1Jm5/mFLkp1DNkS9bsYH+ajJGRZuVdrvSnodkPu9Gr7AbUkros3tU 6NBeKVdiXo5bojxwixUZFmGfZn5YUU5qDJgMcldAq2EuuY46Vq5kkYI5bC3OgAKQfyNG MNIlkrF7/03hbTNryxYdfvwipdfhBEZcsg0dA0f2LGVyYO+y5l2bTZheUghodYP5aOVx Q50wZZfhMWAF+LRSbY2AuDPS2qZOUZwY+yUAXeK3AiP7cr11bjP2McIB30TB7uDx6Egk QGsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727894374; x=1728499174; 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=TshTQF/TSvyBj9BzMK4vj8B3U8KlfkUU2BHBkg6GX/iusCSLlL5ihOdQm8gk1ynZ8S 14NniGucmf1AA0b0pOKZkzPiJ6ix0BKABLTOuh6e8uGBl5lw+39U4yH+dauakIy8whVQ k5DHgYKH3GEnrmOQN92iGE21l5OVB4L+ud8o0Ab7hfT1i6KbrwkERQuOAq2/+QGYymTZ 6nYGxAXGYEVmBuRPIRWw36+aNwV+SHDnbldygpWaek0DkA/k+GtqzIZXra7vd/tx3PNI kNUNzhFVy7e3zwo3oh6yJ+cgLbwfl9Lca5+T5wJ6TeEyvOZ+ebM46sa5zZELAV4c3qxT /ryA== X-Gm-Message-State: AOJu0YzIvK3mj96Za3CO73dDyWPGg4vSe3amqisql/Q1sBdJT+nBhBiI 4TIhte4b7gNtPtJaE+21vlgO6mZDDBAzt+fLTJNPtSO42Y/FURn/CruAQNG1j6vGwvxBCZNr8rR P X-Google-Smtp-Source: AGHT+IFr+Cv4FRYikkJsk7c9ZPTYdjt3k9My/5RRFES+7iQtj7gxhjZTbd6BqkiToPHhT3zRzAs/nQ== X-Received: by 2002:a05:6a21:680d:b0:1ce:d08c:2c10 with SMTP id adf61e73a8af0-1d5db19858amr6387425637.28.1727894374223; Wed, 02 Oct 2024 11:39:34 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71b2649b0bdsm10104362b3a.34.2024.10.02.11.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 11:39:33 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Konstantin Ananyev , Ray Kinsella Subject: [PATCH v7 07/16] bpf: fix free mismatch if convert fails Date: Wed, 2 Oct 2024 11:37:45 -0700 Message-ID: <20241002183918.161656-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241002183918.161656-1-stephen@networkplumber.org> References: <20240927204742.546164-1-stephen@networkplumber.org> <20241002183918.161656-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