From patchwork Mon Apr 19 13:36:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Claudi X-Patchwork-Id: 12211857 X-Patchwork-Delegate: stephen@networkplumber.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BBEDC43460 for ; Mon, 19 Apr 2021 13:41:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66B8E6113C for ; Mon, 19 Apr 2021 13:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241184AbhDSNlj (ORCPT ); Mon, 19 Apr 2021 09:41:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43513 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242025AbhDSNht (ORCPT ); Mon, 19 Apr 2021 09:37:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618839439; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=BBf1Nxj5erqlDJNTuzs4e7olpX+wS5exxMu397gD5cE=; b=UY9OJ69bCfFQNuxhRTRu+yckY7Qc5BvEoa5Os3o0jL6RaL7kxk2OSX9POBwUo1Dqp1SJ3O nfhzzSoHXk6JthVypwQLdnyWoOcmjPIvBZ40RyHmupmrjSiuJISRIaokBbdWaR7Q5rNTuw lX66zTxXmlPx2uvWWLdn8hfa5FVvAJ4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-84-eq2RziwtMJm8Mmw45o6z3Q-1; Mon, 19 Apr 2021 09:37:17 -0400 X-MC-Unique: eq2RziwtMJm8Mmw45o6z3Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49EF8107ACE4; Mon, 19 Apr 2021 13:37:16 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-159.ams2.redhat.com [10.36.112.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46FC5610F1; Mon, 19 Apr 2021 13:37:15 +0000 (UTC) From: Andrea Claudi To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, dsahern@gmail.com Subject: [PATCH iproute2] tc: e_bpf: fix memory leak in parse_bpf() Date: Mon, 19 Apr 2021 15:36:57 +0200 Message-Id: <61ec0f2e5054f0d98fe870b5ce995b9b82a09ff4.1618839246.git.aclaudi@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com envp_run is dinamically allocated with a malloc, and not freed in the out: return path. This commit fix it. Signed-off-by: Andrea Claudi --- tc/e_bpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tc/e_bpf.c b/tc/e_bpf.c index a48393b7..517ee5b3 100644 --- a/tc/e_bpf.c +++ b/tc/e_bpf.c @@ -159,7 +159,9 @@ static int parse_bpf(struct exec_util *eu, int argc, char **argv) envp_run[env_num - 1] = NULL; out: - return execvpe(argv_run[0], argv_run, envp_run); + ret = execvpe(argv_run[0], argv_run, envp_run); + free(envp_run); + return ret; err_free_env: for (--i; i >= env_old; i--)