From patchwork Tue Jul 9 18:31:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 168755 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8896015ilk; Tue, 9 Jul 2019 11:31:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNfFNkZW0nPFKbKfYsmIanmUJQiNLaIFiU0r166OIzhG4ApkCbWw4qRIOeiqbkvmcqqB1t X-Received: by 2002:a17:90a:898e:: with SMTP id v14mr1586524pjn.119.1562697110393; Tue, 09 Jul 2019 11:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562697110; cv=none; d=google.com; s=arc-20160816; b=Cty/JKoykZGPjRJWw+H8ccz8HSwa1Gi1MKNpB1zVmkBjVisCt2LJr6+w/7qTyTyPSm xWwxLhwGS5wDR4gArx9+Fbr7ICSIk3Uw85D/gmh00Is7OyHO8XdRVBufm8/JScRVzJ/J pEzYBYb2+EasXd7fYxaeQqVNa4qrALP6S/j9M+J0kPxXnXo6iw03mmuyUO2O6DGQ1p4z 2jS/VA3hhMGBs4/VoqagNe/+Yx1F2y28aEsXe4uUjJuLkK8NYqArZFAvcgKdEiqPtm0Q C88w/UwxzEVx4XTGxSMn3Oy2bGnugw8Td2lpCd1ebPwQWAbYcQ+cDNnoAWp+i0SV2FY+ iz+w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BhCV8DtjOWI/nh3PnXd5gSJVWobdN5eToBycnnF+4UU=; b=rSNwB5KVweWTzM6gtuODv+xCe00s54ZLxS8Xp5W4qIwX1sNwispGBIjZxQq1piWQqE rGRjiAZxhYEw2T0CUH9D+8iMyDyIAGEDE38r06gBMSEinLLfeGvrOMqJn4x1jd1Od087 A5Z2c5HFIs+QhXGvF6dUIv/Aqs99g0Yhyr2GkKSJs6jklYaTYhUS/yQBE10GYB3ojZcR +f8acI5jHILIavC3JNugNSji3WBW3cGWJ6cTlVFRjmpMdbccNMgLpW3Kb1QEV7WSE7UM 1lM9SxQ5DxL0AVPIESrB8MTAFwOFlmPiF6XFw9UVsmF9DoS3JntN2YT5pjlA89wmunlG xufg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=F2bTdox0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1si18161152pfn.129.2019.07.09.11.31.50; Tue, 09 Jul 2019 11:31:50 -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=F2bTdox0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729042AbfGISbt (ORCPT + 30 others); Tue, 9 Jul 2019 14:31:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:52976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726881AbfGISbs (ORCPT ); Tue, 9 Jul 2019 14:31:48 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.35.11]) (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 A82CA214AF; Tue, 9 Jul 2019 18:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562697107; bh=aVZ0iIxfrqicomtqFbAEDq8CdAhVe14Oy+wL/zknopw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F2bTdox0H8xFhe/mRht+zvTN+TcE0KZL6eOYL7Iz06XZSNfhoYDeICfpNcc8HlFmh qffXnJhZjtN1ZwyWplr3H34bUl2VVKmNx01Fi5UBTmfdAgHzKSBsOg0I94n/LbQfqd jSkDNMv8Doc+kAOxjTV9cmEcolzf/VhAHmMpoSGY= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Leo Yan , 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 , Peter Zijlstra , Rasmus Villemoes , Song Liu , Suzuki Poulouse , Thomas Richter , Arnaldo Carvalho de Melo Subject: [PATCH 02/25] perf stat: Fix use-after-freed pointer detected by the smatch tool Date: Tue, 9 Jul 2019 15:31:03 -0300 Message-Id: <20190709183126.30257-3-acme@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190709183126.30257-1-acme@kernel.org> References: <20190709183126.30257-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan 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 --- tools/perf/builtin-stat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.21.0 diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index e5e19b461061..b81f7b197d24 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1349,8 +1349,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 {