Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp706272pxv; Thu, 15 Jul 2021 14:01:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzahXKiMot5fCURz08zzbrRGKH3+lWcVtj3symzaYvwYLCW2BHnflBp/qlT79nLGHYdJj+d X-Received: by 2002:a05:6402:90a:: with SMTP id g10mr9703263edz.365.1626382909381; Thu, 15 Jul 2021 14:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626382909; cv=none; d=google.com; s=arc-20160816; b=udMpsFglYem1qIH9+WUf18rCKbpsVxT3p+50U+gDFi0Sc8MkB2Jp9nGHqnXHoNFcXk /Q90xamEzUVwNEhENd/7zv0kz9KUbnO3WcL/B5CDTy60Yv3Md1nU9b9bHOE5M+xAp0Ft ERwOtPeJ1k5dbc3f5SeUHEa0S/RdSlheuVQkY8o3kUmI+iIML8ysKi1RZmcfgE8o2WMP 6IW9epBUojishiRoh4bchsMyFTR3UIxLd+oLwFJDPTDs2ZJapwbIg/vDOPGvOQcbj+td tLJpHxepWrS3Y/QTn5IuErLvULPk1C6D4Pmduu2g5zHthmIKKkq3zqbrRNrBK5wF6tYI wy1g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YzH8sqrASJbCt/2FNg8W8hQhxyFOqQaNvu5d409D1Xg=; b=MkmkR8M+I2Uk0lh0K2uLAFSUW90QP6GLCNU3cowV79BCBMaPFRCNrk9YHLs9AJykxK 6IFeWPoHaBChS3buqTyW7kowSmX9pfd1Z5Q+GdEminY8W3cmgJ8/k6NZAk/6sz2kwgAp x6T1tcqFUbimo2klyzVzBjnLj+ikWLkdycK9PlkuniMF/IDmPgmndWdTDXCPXXwiTsBb VVSAUZFgzJtMpx6V4gdsdQL8uBBWD8WmoT2i7eZzBjWNmfwACe5NrRRiV1ArfHlcfs02 0ylyzwZUx4nP3zVjgRUpwq5dfYqoHgEwdCRgCtTGc4OyQhlp1Gz5DOq17/m532CkcZXB N4rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="lv+1lQm/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 10si8108187eji.282.2021.07.15.14.01.25; Thu, 15 Jul 2021 14:01:49 -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=@gmail.com header.s=20161025 header.b="lv+1lQm/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233069AbhGOQKd (ORCPT + 99 others); Thu, 15 Jul 2021 12:10:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232080AbhGOQK2 (ORCPT ); Thu, 15 Jul 2021 12:10:28 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F7C0C06175F; Thu, 15 Jul 2021 09:07:34 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id o30-20020a05600c511eb029022e0571d1a0so3987017wms.5; Thu, 15 Jul 2021 09:07:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YzH8sqrASJbCt/2FNg8W8hQhxyFOqQaNvu5d409D1Xg=; b=lv+1lQm/pVmOsbm18WDThNHsNReHdf8X9dopzMS7aDUCZASJODkllgcXf7gRj9ZUdc MWofV6gdui6af8lzuQwP07KhDJKxOhBcR/0XKmi+PsYfXIITuQfkiA9psz/We7NbW3nk D+KItQEItzKn6L7L+PfalP/Rcu42o2aNZt2MDzlodJ7li+QCyY30Iea/SSmny8Ntf/ph Srb2/D/ERwBXBfGW6xshxuiE7iNFWVyEi/zUfx4MNUfhUEog7X92MzBBOOVSK6wFRlCh lp3b+6/H/JjtfOhdPlh/m15mOvKStrq5khO6+f6g3N/KLkjzZ5Yp7h7C6zkw7ZV0k4Xh v7qw== 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:mime-version:content-transfer-encoding; bh=YzH8sqrASJbCt/2FNg8W8hQhxyFOqQaNvu5d409D1Xg=; b=nHW16gvfwOQfOWqAmmUaMd0eBPb/Nf0Xgf5qe/fw6LYM/ZaaZQs7hcncbyW08YqK1s BH4KYOuEcgimdisqqs7Hd4U0RfkksKmYzneS45756aoyyLbrdrbMLe8Z1+Z3imLcdoB6 nUORRCOW0vJdF/BLaKKcSo9hAP1xK0Dtqdxf3RWTxCXxbfFZyhhXh0LqEgLAzi6jgLKE Sy8x5AxoCIl60bkyvQqq9iql591NqRv/KNQEGp+hldROtbLy8R3THjp40sVj3B7tUfrT 46J1pgVb/7Wc2Rj8oGzwweStSYTr6YLLPY6gR+x4z4E0VNw4SbNLrpMX4eYR7FBMTjqF IeZg== X-Gm-Message-State: AOAM5310r9x0WddDyRu3EDmpatJtOHrvstu24nwUW8IUhb9MyCsuUP/r AMwcf6OqJ9kmm4e0Q9xfNAc= X-Received: by 2002:a05:600c:246:: with SMTP id 6mr8768694wmj.143.1626365253110; Thu, 15 Jul 2021 09:07:33 -0700 (PDT) Received: from honeypot.lan ([2001:b07:6456:fd99:ced0:db1c:53e1:191e]) by smtp.googlemail.com with ESMTPSA id k13sm7446952wrp.34.2021.07.15.09.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 09:07:32 -0700 (PDT) From: Riccardo Mancini To: Arnaldo Carvalho de Melo Cc: Ian Rogers , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Riccardo Mancini Subject: [PATCH 05/20] perf test: event_update: fix memory leak of unit Date: Thu, 15 Jul 2021 18:07:10 +0200 Message-Id: <1fbc8158663fb0d4d5392e36bae564f6ad60be3c.1626343282.git.rickyman7@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ASan reports a memory leak while running the 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 --- 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 932ab0740d11ced6..44a50527f9d95170 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.31.1