Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3812697ybi; Mon, 29 Jul 2019 13:07:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3lru3iJRajOOX1JadhKfKjCDXZpj70lKvHS+Z/5q1UPuLWjgV1tAaDO4x2T3wgcYb3A0x X-Received: by 2002:a63:8c0e:: with SMTP id m14mr90995955pgd.219.1564430826925; Mon, 29 Jul 2019 13:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430826; cv=none; d=google.com; s=arc-20160816; b=WYgpkzfDWepB8J0APtnbg8XdnH7rTyxm0VvV62ZBeuDRm0AGDH8Ew/MdN2MH9ju90g LXhoIk18YM+LcB02qgDOYwKJTnZqNeRUJys+8m7rwXscVvOmf7bbMm8NZo0ylhbv+RBQ 6hZAbVEC7XqFTUktlDQQAtP7MN4frA0MK+2LZ/jP6sZLLYKYsN9iTSX80o1XFibA4M2z WMZNtT52unlTmikuiYUjMyz9yJDlSUxgHC9owwDBJcUGI/Pwm9qD7rcR9V1Mzk28RDjh Q/YGayGWjsK2864dbTSHPH4otzOSv2uMEkq6tmnqv4O+ELdkZBHA4ua+9qkxYiQwxTzd wqJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Uh76HhNLPGDKle1mHxb9D/HqzA0KcR9I6IOhGk1pCoQ=; b=UMU5ARDHZ0dCfAry+Um2Dh6K00dtq2lniZHqp4ET681CXWyt0zqicMgvTMGjeqS6zx CZWFqPiYefIzlKU2djIO83v9mNrdsTJvwD/fPTPJ4N7G9GePZHat7OMCHr3E1O7IApIP q7dljDmnRwKrSLweH233AksZW5n1H66DIG1fBccnRPJkEUNMXlb/1PiZYfigDzzvakTC dz+bW3nbmcE3jRW2CU2Oc/6W+fVTiM1nv7G6/EDJ9aedS995b/X3gaBZ1ehRyOfcjfh/ 941ftkEaPR8+zC/wUS47VSrrXBMq//NnuAy631V2mI3Mm4MBPnh/wuV8xgn7YyitZB8J efZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2IjNOujd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z190si29638809pgd.303.2019.07.29.13.06.52; Mon, 29 Jul 2019 13:07:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2IjNOujd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389495AbfG2Tm3 (ORCPT + 99 others); Mon, 29 Jul 2019 15:42:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:58208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388602AbfG2Tm2 (ORCPT ); Mon, 29 Jul 2019 15:42:28 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 56297205F4; Mon, 29 Jul 2019 19:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429347; bh=/gfFttHCT6rboXDwNjRUT/A6t0RlSyuDn4xdgAbhUcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2IjNOujd32yHWkqViHhkHCJuqn1QEdQaFrdevGTxLSUcZGUzWa58iYawmb4XDtmqV sXRlwL2e13tBEOB19sGPlN4bYT3/9ju7m+ppYL428WBpQHxQ3/t5bhrAz89jzZI+xq 0H13tFchQBN/QUriUQI0YAQSLGROnwiK9si63vzQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leo Yan , Jiri Olsa , Adrian Hunter , Alexander Shishkin , Alexey Budankov , Alexios Zavras , Andi Kleen , Changbin Du , Davidlohr Bueso , "David S. Miller" , Eric Saint-Etienne , Jin Yao , Konstantin Khlebnikov , linux-arm-kernel@lists.infradead.org, Mathieu Poirier , Namhyung Kim , Peter Zijlstra , Rasmus Villemoes , Song Liu , Suzuki Poulouse , Thomas Gleixner , Thomas Richter , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.19 068/113] perf stat: Fix use-after-freed pointer detected by the smatch tool Date: Mon, 29 Jul 2019 21:22:35 +0200 Message-Id: <20190729190711.748983025@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit c74b05030edb3b52f4208d8415b8c933bc509a29 ] Based on the following report from Smatch, fix the use-after-freed pointer. tools/perf/builtin-stat.c:1353 add_default_attributes() warn: passing freed memory 'str'. The pointer 'str' has been freed but later it is still passed into the function parse_events_print_error(). This patch fixes this use-after-freed issue. Signed-off-by: Leo Yan Acked-by: Jiri Olsa Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Alexey Budankov Cc: Alexios Zavras Cc: Andi Kleen Cc: Changbin Du Cc: Davidlohr Bueso Cc: David S. Miller Cc: Eric Saint-Etienne Cc: Jin Yao Cc: Konstantin Khlebnikov Cc: linux-arm-kernel@lists.infradead.org Cc: Mathieu Poirier Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Rasmus Villemoes Cc: Song Liu Cc: Suzuki Poulouse Cc: Thomas Gleixner Cc: Thomas Richter Link: http://lkml.kernel.org/r/20190702103420.27540-3-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/builtin-stat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 40720150ccd8..789962565c9c 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2497,8 +2497,8 @@ static int add_default_attributes(void) fprintf(stderr, "Cannot set up top down events %s: %d\n", str, err); - free(str); parse_events_print_error(&errinfo, str); + free(str); return -1; } } else { -- 2.20.1