Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3274894pxk; Mon, 28 Sep 2020 12:58:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyYeb99hy6vyRUOCU4Hf3TgO5jImKQcimmInmWjId4VmuVoRkxrFVKT1iSZ/IY4onyhVTi X-Received: by 2002:a17:906:4093:: with SMTP id u19mr411512ejj.520.1601323108112; Mon, 28 Sep 2020 12:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601323108; cv=none; d=google.com; s=arc-20160816; b=V7xnzdntGTQL4ul6W8ASk85kQ2GBWy1DklbPdtcct/zXiA7qZUK8n8AT666kuJtWXO Cf+CR2rj8JN9fyA6AJ23dJHjfsj8/Wu7o3Wm/W2egHA2nRf6od9FvGc/GPfK7r+d1ysu 5Bllul55S32cAO1cGuXqTqapjZEV/AZxwnKH2WplXv2rswClvLJkIfabQbF3RiezQnGD /oHbgdPbo/c27XaQqdFKHJVH6vSLyYP+kfoUJv6hwuI0cEITBZPVe1e8it4UO9T63VKJ bATmYReDEXMbDDP47mM3i6j8c/oOYx3SGn7LoVnoQ3IyI5FKNSbC/9G/8/hyPuuoeZ/B Ywww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=iNpDShrVH0G/yhVSSFMZRjI6zLZIrWDL5WcnPUrYGzk=; b=gBB/U5I1564K8YIouIyii1LK4J3JWZbc4ohpK7ZB0TjqJwdsy1C9I+GNktaRsl79Yv Ob3sEZnZgk3TKCZ3Cydgk3PAO0ncenuPJj39Zu4QaTAWeTecMqKqRJb+3AuzCXvkOVTU QmPonqRQakkoLqA2qkXHmbtY4QMi7sgCPMBmr/qHX5TSES5fg8CAAEEo6yU+8wbO/nlN qXGUK0JqxhYDWtFNr14zrrLheQ82zAce++MvoJfF3nIHjVDmQLOk6fioTbMFQaP+NTsD ohhRAa+R+nxahK80kU/DJYwh1tYzmMjUKuTmeo2o+6qeOdvB5bzUwDuxeDQaAwCZOrfz GspA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GyPa84B2; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u15si1327524edo.55.2020.09.28.12.58.05; Mon, 28 Sep 2020 12:58:28 -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=@linaro.org header.s=google header.b=GyPa84B2; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726551AbgI1Typ (ORCPT + 99 others); Mon, 28 Sep 2020 15:54:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726325AbgI1Typ (ORCPT ); Mon, 28 Sep 2020 15:54:45 -0400 Received: from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com [IPv6:2607:f8b0:4864:20::e42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39685C061755 for ; Mon, 28 Sep 2020 12:54:44 -0700 (PDT) Received: by mail-vs1-xe42.google.com with SMTP id j185so1541681vsc.3 for ; Mon, 28 Sep 2020 12:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iNpDShrVH0G/yhVSSFMZRjI6zLZIrWDL5WcnPUrYGzk=; b=GyPa84B2gDRjXkfCs6NUDZmJEyPJ4/aOBxxs5SluRxk+xDHeeMdBdYam31QWJvC7U1 L9JYguE062Ayx4K6/mqBIzcFcUIyZ7fdcr5PTF3vFUzX81ZxHjjButBuMRTYjMcD/JWM +0/du/7KsYoDnJ3945FToisyazVuA5fS0RSRo9veeBudFhqKsml63C9W4od0s5qEMqE7 BnCcSOSIB8yUBs/UAHphk7LO6Ny4AN5wMlktb6d2YvSJf9E2sbYeXJ7jdG2GIR1+JhBq 0e9+5xbp2gPt3qIQ+sWYpcF3ken54zKdkbq0znlvpiFPA7DbMClVE+7NhFXTrnWpQIRu 0Ygg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iNpDShrVH0G/yhVSSFMZRjI6zLZIrWDL5WcnPUrYGzk=; b=HqWDk2kGuXXW5fKMSL8rsXl0zZ9lSfBVUtPGhLoneu4dT4vvRaM90MjFb4QNloN1D0 q4YweSArqS+KiDqXrTj3gNLXMI038T1fcHhvLkveX+qycarCbiySl3Uy5KxpUgU+ujCK H2IiqYwRD1JKfF/n9bRXK/w7zSpWExn5NMaLcWg7lRtoSUvcXodVBf++iFkVKXMs+wU7 1DZhPPyOuVOhGVTIwekGc6GndcD4RF2d06ewOOQYpBk9ppyp1ZSkKD0gGf3ppIq0vfaC ZpKtsL7jbwac2ku6paxaa4zfPHJEqr8TQjOhbBABax6aCGckBtEEmRh3xPbdJQJ6bu26 xowA== X-Gm-Message-State: AOAM532ZY6nsxw+ww+MEo/7j35D7CWiQN9BPJrwr7u+G6ROlVuP3lg/g PAFtd3gkJ25FVXjSGugSdxDXQ1N5N+4+diRz0CCldA== X-Received: by 2002:a67:bd12:: with SMTP id y18mr893885vsq.45.1601322883397; Mon, 28 Sep 2020 12:54:43 -0700 (PDT) MIME-Version: 1.0 References: <20200918021220.2066485-1-sashal@kernel.org> <20200918021220.2066485-112-sashal@kernel.org> In-Reply-To: <20200918021220.2066485-112-sashal@kernel.org> From: Naresh Kamboju Date: Tue, 29 Sep 2020 01:24:32 +0530 Message-ID: Subject: Re: [PATCH AUTOSEL 4.14 112/127] perf parse-events: Fix incorrect conversion of 'if () free()' to 'zfree()' To: Sasha Levin , linux- stable , Arnaldo Carvalho de Melo Cc: open list , Ian Rogers , Adrian Hunter , Alexander Shishkin , Andi Kleen , clang-built-linux@googlegroups.com, Jiri Olsa , Leo Yan , Mark Rutland , Namhyung Kim , Peter Zijlstra , Stephane Eranian , lkft-triage@lists.linaro.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 18 Sep 2020 at 08:00, Sasha Levin wrote: > > From: Arnaldo Carvalho de Melo > > [ Upstream commit 7fcdccd4237724931d9773d1e3039bfe053a6f52 ] > > When applying a patch by Ian I incorrectly converted to zfree() an > expression that involved testing some other struct member, not the one > being freed, which lead to bugs reproduceable by: > > $ perf stat -e i/bs,tsc,L2/o sleep 1 > WARNING: multiple event parsing errors > Segmentation fault (core dumped) > $ > > Fix it by restoring the test for pos->free_str before freeing > pos->val.str, but continue using zfree(&pos->val.str) to set that member > to NULL after freeing it. > > Reported-by: Ian Rogers > Fixes: e8dfb81838b1 ("perf parse-events: Fix memory leaks found on parse_events") > Cc: Adrian Hunter > Cc: Alexander Shishkin > Cc: Andi Kleen > Cc: clang-built-linux@googlegroups.com > Cc: Jiri Olsa > Cc: Leo Yan > Cc: Mark Rutland > Cc: Namhyung Kim > Cc: Peter Zijlstra > Cc: Stephane Eranian > Signed-off-by: Arnaldo Carvalho de Melo > Signed-off-by: Sasha Levin stable rc 4.14 perf build broken. > --- > tools/perf/util/parse-events.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c > index 2733cdfdf04c6..ba973bdfaa657 100644 > --- a/tools/perf/util/parse-events.c > +++ b/tools/perf/util/parse-events.c > @@ -1258,7 +1258,8 @@ static int __parse_events_add_pmu(struct parse_events_state *parse_state, > > list_for_each_entry_safe(pos, tmp, &config_terms, list) { > list_del_init(&pos->list); > - zfree(&pos->val.str); > + if (pos->free_str) > + zfree(&pos->val.str); > free(pos); > } > return -EINVAL; util/parse-events.c: In function '__parse_events_add_pmu': util/parse-events.c:1261:11: error: 'struct perf_evsel_config_term' has no member named 'free_str' if (pos->free_str) ^~ In file included from util/evlist.h:14:0, from util/parse-events.c:10: util/parse-events.c:1262:20: error: 'union ' has no member named 'str' zfree(&pos->val.str); ^ util/util.h:27:29: note: in definition of macro 'zfree' #define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) ^~~ util/parse-events.c:1262:20: error: 'union ' has no member named 'str' zfree(&pos->val.str); ^ util/util.h:27:36: note: in definition of macro 'zfree' #define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) ^~~ Reported-by: Naresh Kamboju full build link, https://ci.linaro.org/view/lkft/job/openembedded-lkft-linux-stable-rc-4.14/DISTRO=lkft,MACHINE=intel-corei7-64,label=docker-lkft/938/consoleText -- Linaro LKFT https://lkft.linaro.org > -- > 2.25.1 >