Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3718915pxv; Mon, 26 Jul 2021 10:10:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrraPBjCAwlR9mDDDhFVE3nGyp4NNO+pc2jayuotoQSLwxZKtjh1xnf3m8FNfdZ6XfkRSZ X-Received: by 2002:aa7:d48f:: with SMTP id b15mr23127950edr.271.1627319402822; Mon, 26 Jul 2021 10:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627319402; cv=none; d=google.com; s=arc-20160816; b=Xb4h9nJzJ3lzI5xv1/N9RvHhOk71Rjj5hQDBj0bFTL00ETL6BCfgST4mrv0GbiQyxi +cZB6hKekWj2R72dNOVSmo+78bLWfJcMWr8Sjlo8v3hVm3Qlp316Auh9A/vdzz64PMtK VVuR2dg2Inr7fWUZFcoKb3JIZ525CLN/Aygsv9IMzVgTxgi9pOMRYxJKnzoADSsBb3KR QPDgx4xq3G4ueWWzkWPY+CPBJNvmsbzp7ZKatPyFnGAh7C/K8qzdnm1O3qqPa+CPPe0X WhLEFXoKGhIRZQ0wKq57ydrTfYCNAiN4SwgTxWlv6FCCnWUeF3SuqCi7LcKUaO20w+oD jMYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cYa/zZNMlxUPIV1bbVK/an3beJDDnY7RTYVYJ6nDuOU=; b=Cb1UO/QIYEC0kX83rG5SD7PFk8XZa57gaNUZaY+v8SDo9EZNuFiluGlJWWJti24GTK fedjeZnfXr/VCnZE0rWe3bJIkF6JygB9pnN5LqfKPVyjP56aNoTLDxANvI6nuJwWV/CB C33RC/h5gKOPbkj+KHy9FzbOFbHa+c9Yz7uSr+t0ZHh88dw0C3OBHVB8UmpIBb6RTBQk g0XI9q4MluPqiukO5QFtq9t0UiBXSrI+KkX9SqWq0xAZzN8Jt9m6/WN/qMqz3ZCmxUOu 5cebChzCUW2j8RhDB+llyJtKYnKlO7hdE1BnCSedmux2gpIHx6h/LhwVeydjcmemB1pN 9xRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K113LDGP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b8si483074ede.407.2021.07.26.10.09.36; Mon, 26 Jul 2021 10:10:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=K113LDGP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239239AbhGZPvT (ORCPT + 99 others); Mon, 26 Jul 2021 11:51:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:41424 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237889AbhGZP32 (ORCPT ); Mon, 26 Jul 2021 11:29:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DD4BD6108B; Mon, 26 Jul 2021 16:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315759; bh=t5MaalEEDiyRQpeumLbYQ0LeJcE8JWiAg4nqGyxTB0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K113LDGPsmYvyoP6WEtIxoPB3DAoQoD0aAZCsz6hH7U0+h8SAnR1Tlu55mYlhV8Y2 7BWfIrvVp9Pr7hfg6MNnaAI1L03F5CWaGhS0SW4NQ1wtRyDmI+Ts0TcNjHQZ8ezpC1 NLo360/hRacSHYORhua4+pClWxwMW823Kv7ppHBg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riccardo Mancini , Ian Rogers , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.13 055/223] perf test event_update: Fix memory leak of unit Date: Mon, 26 Jul 2021 17:37:27 +0200 Message-Id: <20210726153848.063006572@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153846.245305071@linuxfoundation.org> References: <20210726153846.245305071@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Riccardo Mancini [ Upstream commit dccfca926c351ba0893af4c8b481477bdb2881a4 ] ASan reports a memory leak while running: # perf test "49: Synthesize attr update" Caused by a string being duplicated but never freed. This patch adds the missing free(). Note that evsel->unit is not deallocated together with evsel since it is supposed to be a constant string. Signed-off-by: Riccardo Mancini Fixes: a6e5281780d1da65 ("perf tools: Add event_update event unit type") Cc: Ian Rogers Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/1fbc8158663fb0d4d5392e36bae564f6ad60be3c.1626343282.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/tests/event_update.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.c index 932ab0740d11..44a50527f9d9 100644 --- a/tools/perf/tests/event_update.c +++ b/tools/perf/tests/event_update.c @@ -88,6 +88,7 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unu struct evsel *evsel; struct event_name tmp; struct evlist *evlist = evlist__new_default(); + char *unit = strdup("KRAVA"); TEST_ASSERT_VAL("failed to get evlist", evlist); @@ -98,7 +99,7 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unu perf_evlist__id_add(&evlist->core, &evsel->core, 0, 0, 123); - evsel->unit = strdup("KRAVA"); + evsel->unit = unit; TEST_ASSERT_VAL("failed to synthesize attr update unit", !perf_event__synthesize_event_update_unit(NULL, evsel, process_event_unit)); @@ -118,6 +119,7 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unu TEST_ASSERT_VAL("failed to synthesize attr update cpus", !perf_event__synthesize_event_update_cpus(&tmp.tool, evsel, process_event_cpus)); + free(unit); evlist__delete(evlist); return 0; } -- 2.30.2