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 36A9C45AE3; Tue, 8 Oct 2024 18:49:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 36AAD40E5E; Tue, 8 Oct 2024 18:49:07 +0200 (CEST) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTP id D352040DCA for ; Tue, 8 Oct 2024 18:48:59 +0200 (CEST) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20ba9f3824fso44734975ad.0 for ; Tue, 08 Oct 2024 09:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1728406139; x=1729010939; 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=hDyRp/TbbFmNsejql/uDXnAsQTvzCUR92WU1U2fRxGHDH6GPgEsqsc9jTpLEhvHN/q TTjxzCsra1Sg71/fNp336k5moxqIEUafBWh/KZKTgE7ttoaCsjy4RCWTCQR4KkkIBxGZ tFVNn4clAHRMkGqwVoZGPM6nblLHH9AYN+NryhnpfPTdgSgbvL3t1jPfIbRxKYkaorlO U5srNjUxxbjH7au3OOlemfD8nF+qFE3ucrSuQcZSqu/D5WyFIr/gNXOyZPAkxLCU5AU3 vIHj5qHIuNZd7/OgxE7+l9S9dUsZSTtyO/vBkotPb1GLPumGCza2+OCOK97YqF5imqa3 Po2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728406139; x=1729010939; 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=YUsvFvyVN/KXXRoUAUaNV+/2ZFxicoz0VvMPY8qGp05wIuAKYSiPXDqrUCQQWldvwu AOV4Ecek4vz1yKFpeP9Mx+GolRIHu7SzBRGB78jJ4s2tIVSSwaodmoidBaYp+zIc/79T 7KyTBOqdzsQdUJrWHnkwsbx0WqiWDlelNK/mVNqQDPRKfvYIN4gQaxkh/dsKHDtCuzj2 Sf5SbhkdXX+0qXfbi2n4NX8QySe3KTMGeySTQrFWqehLm+QD6aIy9cw2GWi6gfTqyF9s aR2yOmfONkyI4pi5XE+bm8/QG72zx/2mRfrposYcO8FT43BqYOhGJNVb3q2Q/Kw99Jc5 biFA== X-Gm-Message-State: AOJu0Yy+DJkFQVv2bpE6IUN6I70k2zlJqob7kw9P2zF8WFg8WeLzbyDZ ZbYWPn8SFPpHZ5vMBW26d4J2GmN8XD+nDE+nkbFJqr2TSJnQLiA01/g07+Intotg9S7zJGTVhYj mLafmbg== X-Google-Smtp-Source: AGHT+IFn5lavbE3bwe2rupgMq9mjofiVDnydD2oMDojhWZ9iQU6q0lRaKxFbhYbvFuPTmCpMQblrGw== X-Received: by 2002:a17:902:da92:b0:20b:6188:fc5e with SMTP id d9443c01a7336-20bfdfff45emr220740185ad.28.1728406139047; Tue, 08 Oct 2024 09:48:59 -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.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 09:48:58 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Konstantin Ananyev , Ray Kinsella Subject: [PATCH v9 07/17] bpf: fix free mismatch if convert fails Date: Tue, 8 Oct 2024 09:47:11 -0700 Message-ID: <20241008164842.139045-8-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-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