From patchwork Fri Dec 25 05:27:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 352291 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp7504662jai; Thu, 24 Dec 2020 21:30:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzarkxYZa9ZRu9bMK8kZ7X1SQAwGtVIdkkBRsjWQ5UXnQnzoSqjOjXVLrI4G9onpyhOBxGc X-Received: by 2002:aa7:ce16:: with SMTP id d22mr30870682edv.381.1608874229994; Thu, 24 Dec 2020 21:30:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608874229; cv=none; d=google.com; s=arc-20160816; b=k+o1n+nBhRadFmBz5gq7E217tHlYNYCzKgeROv4I6FETONQ/7+rDwlVOwzWSgdTzMU LXKrV95NTDqJD0XCMg+nWhNhbl5kAp1tIJ+j+GfBrRs3Rgmhk/jN0ODR83YjD++GMdM3 mf3hfOeJFCvSxhsg0boC9B5zDocQ5QvzCYJzaWB4rh2KW28TqCC9tL/vd8uY9ve3bzzl SiUl01N8o40yxIeuwtDY382Ll3IzJ+WUMZGoUCCCGTOJJfrss/+imUlTfD/fV+jAWRGw +2JYYanhYCcGn9LcfP662gi0yaxuUCS++w7kvtj7FRICynJgRJCG2O+7g7ahbJ6JGr9e nwug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=fggFNHkIm4LYrEAhkgghWWYvuA1sVNNnoLCFYuyGlq0=; b=TDSRWVJYCcMjkqqmLBhbiK8vtktY0jw9oilvlL0QxMQhxAt8LGMsSxW8wMQJ6hY5FQ Nu2/MIGe8zPYv2hza/EsGlaUdf8n+psiBvpSiSfIQhZ70G6iFdAFHuOJPNSn/lj/uQGq dvjYnbbMBaqHTze7mZFamP5ZYJVYW1pKZGkO2jgNeV0/AzKdggzTGVbVhzTEUvSaZy+7 wNLhHsg0n8kJed4G93iUKIXgy+UzMrn0bEffio70lzjiHx9MtiZ+Uv/t7Tp69LSFHG3b R41fAuaff6piwLWnTfhBJECq4cjlgrMARCWGJ9Kbi17l/RFOseq47s+Zsa033wPjOXbD EjIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kEN7zSRi; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m15si15942053edp.363.2020.12.24.21.30.29; Thu, 24 Dec 2020 21:30:29 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kEN7zSRi; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725863AbgLYF2s (ORCPT + 14 others); Fri, 25 Dec 2020 00:28:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725842AbgLYF2r (ORCPT ); Fri, 25 Dec 2020 00:28:47 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D8F2C061575 for ; Thu, 24 Dec 2020 21:28:07 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id 11so2150527pfu.4 for ; Thu, 24 Dec 2020 21:28:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fggFNHkIm4LYrEAhkgghWWYvuA1sVNNnoLCFYuyGlq0=; b=kEN7zSRi+7riSkXhcZrU8TJWQ4DnunTjyGXKsR69nYEFYNq64ohC72qdjFnHuXBBhC y9REVFiXQvPsL4WT62tXjdG5TZbFfQ5JFtRrN078rt8NzJ/v/z73Z70RYBj60V5fM6IR 2Ipq89qwjypEeyT92GO2qgvF0tobYN3uu4bGeyQHOWXpT4kN3mg0AA2/Edmt//bL8JaM jJ4P7b5tmFsz2GCc/ImFJyv+ts+nQm7jPrAyk/TQ11nLu4TyaFMycOL1Nrnu3Yw/YErp 0B7b6IRQRtKIWwN9Ql17vWPXVnEjn2HFGEnStKxReFEmDIHCXFMnfFJ0AQiLRNm11VbM fODg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fggFNHkIm4LYrEAhkgghWWYvuA1sVNNnoLCFYuyGlq0=; b=bq3f0enbVd44SmhMN5YFYGtVigbiWi/l4ePDOVXFYY6ZjXzp+i0CPYRuOOeG8Gjfbg 15W0V+gnSECy8fkT6z2aJb1QsUctziupJ1+Z2D3VZh2BivERmaY4CsD0pj+9UNKwpPPt CtwRnFBJbnUHHGtKgAx8Ckw7uIPWXYT0y1zxhjIxXazIhSbIwHJBHlxqk+zarZYIZB+g o6hiWGg56rfoc7gGaa7YY5lcvUhENGFQom63DL35QKZ9bVTKG2AKiOvnhh49gdmzNTQi 6LyNnKRPNN5gUBcV0W5UqGL6fpZUJrovyPl614ZEFveR9HzVpi87qAPqaGf72envVikz MC8A== X-Gm-Message-State: AOAM533DsmEOXiczGkr3kb0b4jRR4extdKCfVKGDwgtCrJrlHDjj3Snb pgRXsYJA+JXamh8hcbtZ6igNiw== X-Received: by 2002:aa7:9ab7:0:b029:19d:ac89:39aa with SMTP id x23-20020aa79ab70000b029019dac8939aamr30486597pfi.10.1608874086935; Thu, 24 Dec 2020 21:28:06 -0800 (PST) Received: from localhost ([45.137.216.7]) by smtp.gmail.com with ESMTPSA id g85sm28526152pfb.4.2020.12.24.21.28.06 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Dec 2020 21:28:06 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , John Garry , Will Deacon , Mathieu Poirier , Masami Hiramatsu , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexandre Truong , Ian Rogers , Thomas Richter , He Zhe , Sumanth Korikkar , Alexis Berlemont , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Arnaldo Carvalho de Melo , Leo Yan , stable@vger.kernel.org Subject: [PATCH v2 1/3] perf probe: Fix memory leak in synthesize_sdt_probe_command() Date: Fri, 25 Dec 2020 13:27:49 +0800 Message-Id: <20201225052751.24513-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201225052751.24513-1-leo.yan@linaro.org> References: <20201225052751.24513-1-leo.yan@linaro.org> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnaldo Carvalho de Melo In synthesize_sdt_probe_command(), it gets argument array from argv_split() but forgets to free it. This patch calls argv_free() to free the argument array to avoid memory leak. Fixes: 3b1f8311f696 ("perf probe: Add sdt probes arguments into the uprobe cmd string") Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Leo Yan Cc: stable@vger.kernel.org --- tools/perf/util/probe-file.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 064b63a6a3f3..bbecb449ea94 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -791,7 +791,7 @@ static char *synthesize_sdt_probe_command(struct sdt_note *note, const char *sdtgrp) { struct strbuf buf; - char *ret = NULL, **args; + char *ret = NULL; int i, args_count, err; unsigned long long ref_ctr_offset; @@ -813,12 +813,19 @@ static char *synthesize_sdt_probe_command(struct sdt_note *note, goto out; if (note->args) { - args = argv_split(note->args, &args_count); + char **args = argv_split(note->args, &args_count); + + if (args == NULL) + goto error; for (i = 0; i < args_count; ++i) { - if (synthesize_sdt_probe_arg(&buf, i, args[i]) < 0) + if (synthesize_sdt_probe_arg(&buf, i, args[i]) < 0) { + argv_free(args); goto error; + } } + + argv_free(args); } out: