From patchwork Fri Jun 17 07:20:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: junnanx.xu@gmail.com X-Patchwork-Id: 1644700 X-Patchwork-Delegate: rsalvaterra@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=wMMk9hbp; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=g9ArrujX; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LPW9F3Ngqz9sGD for ; Fri, 17 Jun 2022 17:37:52 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=CziCb7rwFo54Wz2lklJkw5fJ/B8+z6/fG+i2pOaxu5c=; b=wMMk9hbpX/O8Vq mA8m2Z0Y4uRk25430z80qcP+IG8YvVXCQJatUJpSuovxMgtO1lPvAFmNulfmzeGUi8mCvFNpDna7O qS57udsoGOZLwIbGhKt4o4L2SjOthlAVw2jCFWjNkEYLWadzUhEvMEmB8gb63MhAQJwEQEvWYcYAM vuRYqonBrGXwlLkDg9blDqBV4FOEqrOWJG+dx2rBGpKvnFNUILOVLmeLAU3rR5T0h5XygoAeDUG0t o76qkkkcdgzmiWMrzelFmGwkemzvyqGcNxrn1JhZVZHGqN0VSMcQ3FO3PfsOPn72Pr0ykr+4oWuoP BDrrkOGnwMGqHVczVmBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o26SD-005yd4-6I; Fri, 17 Jun 2022 07:31:43 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o26HV-005uzo-IA for openwrt-devel@lists.openwrt.org; Fri, 17 Jun 2022 07:20:39 +0000 Received: by mail-pl1-x632.google.com with SMTP id o6so3196064plg.2 for ; Fri, 17 Jun 2022 00:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=M3icIqNMBC+H18c7yGsooi/dD9EjkA6EjRI64xaFPZo=; b=g9ArrujXjfPJMTrKAlkLaisrm2ucuNUoDXBUIDrXdaXFgdL+P698L4iOksM4irHA1Y dA23B8gF6PmaFV7TccbAq03nKJzJrYNY4qQw2n7w9wiho12DKxzdrQVLY43fOuVf9byC jq1+cvuCqUdQ+zC6KU3MfhTdCrfMUyjUos0U+GMUoEdgO91AmGdYMhNvy+U79pqrXHpt 74SpmOSxq4vcT+07OOyjG4puyVcYYSIw5pzIZQIsspuVf09JVhf2VrCNwobDYLjRX9fW lSkmaT8uYtI+LjIB3sGjKB0+rkhbpN+i11VyGs4XbzTaBEyPYx66SGddEE+zCuzgtjvi vMng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=M3icIqNMBC+H18c7yGsooi/dD9EjkA6EjRI64xaFPZo=; b=Ydx0ZKYMGsx47e4sRJm+OaptHYmwDMXFqm/gFAaQ1v0IL7KTuecRJT7rbGq3HIyOWr NyLzSE9uM9nbmleJKfih2kvZWQPLgLT8/SWXs7IUQpjRSqNe4VEc+qRVY1kkti7j5I+A pEtzU6iuBAWoY3JC8hOEg7geRvWfnNy/xBykd7BgK7emTklGio65qFnGNi7SLmF8u/3h KSQqJmvEWA5y6EQehbzKTob5GC0o+v3T5B6hAOOvbOeImOz6G6DviLmoMvpPl6HzGUGD ywKGEMGFA2Sk2uz4S4djZw6hcfmwdLwvW+TzFlQXrkMxcHaSjy0VPPUXs3bbkGuwoDti BhCg== X-Gm-Message-State: AJIora9FyEUudRjAQiV+JRb6wVYZR5ArOgL0YUu0/VXKRh6EUsBfXbF2 Gwggf4akGLVaCz7AainXRkM= X-Google-Smtp-Source: AGRyM1tUE5K/ZNWRXCGAUapIkcxuUAuu+coKDx7alNGgCIkH9hgoPEaDO/51gGyajgKJzSE8bIUgvg== X-Received: by 2002:a17:90b:3713:b0:1e3:2399:76d7 with SMTP id mg19-20020a17090b371300b001e3239976d7mr9044558pjb.108.1655450433925; Fri, 17 Jun 2022 00:20:33 -0700 (PDT) Received: from localhost.localdomain ([211.95.27.187]) by smtp.gmail.com with ESMTPSA id u18-20020a170902e21200b0015e8d4eb2ddsm2768729plb.295.2022.06.17.00.20.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jun 2022 00:20:33 -0700 (PDT) From: junnanx.xu@gmail.com To: daniel@makrotopia.org, rsalvaterra@gmail.com, sojkam1@fel.cvut.cz, john@phrozen.org Cc: openwrt-devel@lists.openwrt.org, Junnan Xu Subject: [PATCH v2] utrace: fix memory leak Date: Fri, 17 Jun 2022 15:20:04 +0800 Message-Id: <20220617072004.5816-1-junnanx.xu@gmail.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220617_002037_682118_F294C787 X-CRM114-Status: UNSURE ( 8.00 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Junnan Xu Fixes following memory leak: 14 bytes in 1 blocks are definitely lost in loss record 1 of 5 at 0x4079514: malloc (vg_replace_malloc.c:309) by 0x4049A04: vasprintf (vasprintf.c:13) by 0x4046354: asprintf (asprintf.c:10) by 0x8049 [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:632 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [junnanx.xu[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Junnan Xu Fixes following memory leak: 14 bytes in 1 blocks are definitely lost in loss record 1 of 5 at 0x4079514: malloc (vg_replace_malloc.c:309) by 0x4049A04: vasprintf (vasprintf.c:13) by 0x4046354: asprintf (asprintf.c:10) by 0x80491A9: main (in /root/utrace) 134 bytes in 1 blocks are definitely lost in loss record 3 of 5 at 0x4079514: malloc (vg_replace_malloc.c:309) by 0x4049A04: vasprintf (vasprintf.c:13) by 0x4046354: asprintf (asprintf.c:10) by 0x8049208: main (in /root/utrace) Signed-off-by: Junnan Xu Reviewed-by: Rui Salvaterra --- trace/trace.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/trace/trace.c b/trace/trace.c index d895798..6fd321f 100644 --- a/trace/trace.c +++ b/trace/trace.c @@ -381,6 +381,10 @@ int main(int argc, char **argv, char **envp) ULOG_ERR("failed to exec %s: %m\n", _argv[0]); free(_argv); + if (_envp[0]) + free(_envp[0]); + if (newenv == 2 && _envp[1]) + free(_envp[1]); free(_envp); return ret; }