Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3807932ybi; Mon, 29 Jul 2019 13:02:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2EoLDcxKa8e2dhy2lzdq59DTu62uUEAekawG8SUVyNqunR12CykbKpPgHxmQUJ/21pcTv X-Received: by 2002:a17:902:f46:: with SMTP id 64mr112648309ply.235.1564430544432; Mon, 29 Jul 2019 13:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430544; cv=none; d=google.com; s=arc-20160816; b=G5+gsX9FignI0VjVfuy9yTJJEXzgx9cUG9I7fatccypBk4YhBys9ZT3YgU2vhwoigs W/6k1MTuLo09QBcbLH1EUD1aa6lWIbeOciLU5tFyZEPFlKAocGrj0KnmDGhcyd36u+wk 8fU0bfQkOj+ohFTMlL/PAR6rltXqzpPk+xLeAnz3Ac/XuutIJ13sto8JJu6HPhMY6aLi qryWsv0ggBMNuCvLCnJ9Fp+Pk49Zqge5QGt+LSKcIHVCGaABG+6RPWee6YT+vUjfPbMF OmafPsDzdQxdyKBpGaPW7qO7GjH2DsboZrFv0tqxYPdaeVqQLaLBsYP7h21N1KVAUyaF 4RKQ== 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=nQV5oV9zRavxAW9605punxDu7v6UAVN8VatDyWFxsmE=; b=Z1LXQgifhJraxVHhXBeOW1zkH6ZtAR6lE77soITwf2S3Myhl58Z81SUm01WQV5T4lI Eni9TDh6xavbW/6qGODAnMY/53Yw8CR73qdfXDNAimcYuSBc6BvCBiMUGnicfzp3WKzx yNygRKdMD9B3TLNpHC49qtywrWAWd231IhS694rijV/jhKXVQMG/eWcKnP+r68PD9uHz IaqlOvJGkYUkXarj83JlcT4I3ZRcZ8u635+jH1yr5FWFT2stlbhsOrzS37Vi8hLRYk6J dLr22oPheGLU/yghDTaF28I5lGH7/1KZtZZruWxzqN4+2R256yG2TmGfSkOBvHVJanOR 4hug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cuQrj0w9; 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 z14si25904077pju.64.2019.07.29.13.02.09; Mon, 29 Jul 2019 13:02:24 -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=cuQrj0w9; 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 S1728882AbfG2T7m (ORCPT + 99 others); Mon, 29 Jul 2019 15:59:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:44954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728680AbfG2TxB (ORCPT ); Mon, 29 Jul 2019 15:53:01 -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 4EBEA217D6; Mon, 29 Jul 2019 19:52:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429979; bh=Ozxi2XtjT78D7Uj5XdELHqHEiY8/3tGIhhgn9AW5HS8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cuQrj0w9HhbvDlsD+gkpaYU0WYLEdIscZ0X1A9rLbPvLTM8QM/6/q2JhPeM1RrAtz 0M9YxlgOAIy3yYt17p0YOK1OdmjQ9Xdc9mpDAukiwOEn0NTTU6+zjuwfYJ0NeOwypg NYsbTzsAszedlKfRSzCi+K101kEyQ+mloHEXXWkc= 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 5.2 120/215] perf stat: Fix use-after-freed pointer detected by the smatch tool Date: Mon, 29 Jul 2019 21:21:56 +0200 Message-Id: <20190729190759.928908021@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@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 1ae66f09dc7d..e28002d90573 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1276,8 +1276,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