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 8D45A45A6D for ; Mon, 30 Sep 2024 20:46:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DCD7540A67; Mon, 30 Sep 2024 20:46:25 +0200 (CEST) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mails.dpdk.org (Postfix) with ESMTP id E2B8040658 for ; Mon, 30 Sep 2024 20:46:16 +0200 (CEST) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7179069d029so3346555b3a.2 for ; Mon, 30 Sep 2024 11:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727721976; x=1728326776; 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=eJqO6PrPmaz9AJn/dk0qvKrTY4HPaWoGwxtd+9FkWtmkD9WrlfjQVYn0isO5QgP9fE p4vZjhD1IY/PJgl3BL7L1A4wau+tbr3xt7XeAkaXQeyJn7oa2bMR2xwLnHNjX2669+B4 pyQW2CqJ6eZnqAhnndXNWQkkzEbSVSi2NurlNuTyiMifDQ5nq7dUMb7GSGjemHK0oJV1 lgk6qZU4ZMpPZ/rVFGvy6Xd+QvsIjSnUNK2XR4CqyBa/ZKRzSh2j3FKI/K4egeXBvaJO jfu/tN4uf31/tqshhb0k1zQNe//j1D1WJKRMpSGDa1GR2kTFP4axS4CD40WN9EHlQqpN RGRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727721976; x=1728326776; 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=bKrCQVPObhZcBJ1Z2qLhWNKSWeX9KjTZke9n/UDDNiLaf0TQYz0hfnhtEBF6yHfNl9 GTiSY0RSHlM+jaHwCmPw+rLRC3j270ROolhw4VkClGaUqRKF5Ree9nysl4POpFThybKD /H4M86t+7+CE3OxmY13dWO5wdC+6wEHYsWGBt0ZkePQTVUyZiQObaRkjMeOTMrpsZGpP XS8u43kYK/v+YGi+zYaSshJsxYMCl2Yl464YOEfwj/T6X5pDb6/SK24EUibMD7LqZyqn CaTkUngHGxeaM1rC9aBvffS0D52oSrldMfCxGxYx8r7dBaYjI5mp96DeYTfEzDVWfj9Z UiMA== X-Forwarded-Encrypted: i=1; AJvYcCUQxDNZ0anAcrARK3uo1L2E5uj5IEC+uHer+liMVyyUIOBREzy4S3KCnrI/iM3KkqvNPKB+sMQ=@dpdk.org X-Gm-Message-State: AOJu0YxkRES4f2HSC80x9Te+ievAvggD3joH0at3WiN+YicbDUudyaaw eaZbWgB7qQJw+Mwt0R9g3jKjjWvIYgg38s4qIKBNhBxX2bn8K7GKKWy/evSzSPg= X-Google-Smtp-Source: AGHT+IF6hmwSkcPnTZos0AwBlHPVgVozqooUGDIWixF1RC/Lz9Sr9UfakZCNOyTtAmNLBSm/+RO/ag== X-Received: by 2002:a05:6a00:2311:b0:718:d516:a024 with SMTP id d2e1a72fcca58-71b25f37cf5mr20311348b3a.7.1727721976069; Mon, 30 Sep 2024 11:46:16 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71b264bcca6sm6581895b3a.78.2024.09.30.11.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 11:46:15 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Konstantin Ananyev , Ray Kinsella Subject: [PATCH v4 07/17] bpf: fix free mismatch if convert fails Date: Mon, 30 Sep 2024 11:44:01 -0700 Message-ID: <20240930184600.7092-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930184600.7092-1-stephen@networkplumber.org> References: <20240927204742.546164-1-stephen@networkplumber.org> <20240930184600.7092-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 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