Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp58221imu; Thu, 8 Nov 2018 14:45:29 -0800 (PST) X-Google-Smtp-Source: AJdET5d6Eb1oEnBmDZ9A3KhCWrn1LcB5LuCGJGwVYmcZdP3P5o/KzEALC59C0vsm2ZQ8XrX3AmtS X-Received: by 2002:a17:902:bf0c:: with SMTP id bi12-v6mr6584115plb.330.1541717129644; Thu, 08 Nov 2018 14:45:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541717129; cv=none; d=google.com; s=arc-20160816; b=eXLkFu2t1dSOPZCGZdvVs6LchGE4mjKyC7Ub42ccskoSd9oqiAULVmqedJNNLrG1g8 CYwssdAgx7S+isn9NRRNjlUfGWOqmuWWvtG44wWDZ1d/CEgZsAt1j3B0JfShcnguQo+m 823ysD+ZFOcw+JC2ZOqg+IP2K49KsitUP9szNHSDBcxr5SqCUWQMoegi4U54R7wd15nr P4w2dHh4jik2lYt3smNQEkogo0qV7GMAukUtMSICW8dS+nvetMQZlsdbt2GkTKnqjDWC ZAjr3+GrxcFqt0uWIgsO2MP+8mkXFEpTxV3dZWMRVl+jFJivhjsvjIGZHHl1Qtz5fF73 lacg== 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=NJWPLugUXJU+aQ4w13WhFkLOEyWtSxBHJVx+3XKkbM8=; b=xhHtI1Jfb7Cn0DiwjbTvtffLXrB/vu9/XbmXQsMwsCdmlUqj2pR7WHbhBfEkRy3t/8 ZgDy1bYdER4WLy36Z7EEMndbjOes+iFOULKHBMdQFBhaOWWnhMT2Ux5j7sTr12yiDgM8 30rAiAXlzY6BdpTT5/z+EfYibZ1rC+Dnan+uUgLqzhpEEI/DJFXpSqOzfmMgGSoO9o5p KGsutA6rtOWJKwtUD+F1NwjDf8y+4i7Hi+WZ2r4Z1/pFsxCZqiqd9ilc/TyZKa2dMHBk /DtM8DppsCdqkgMGdGrSmAW+hz0DaEWw1Cv8Xszd+KHHgeHO20++MtBJ5KU8/lLTJiFJ 1a6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nbmnVIEa; 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 j5-v6si6010665pfb.211.2018.11.08.14.45.14; Thu, 08 Nov 2018 14:45:29 -0800 (PST) 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=nbmnVIEa; 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 S1728708AbeKIHdI (ORCPT + 99 others); Fri, 9 Nov 2018 02:33:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:48542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727633AbeKIHdH (ORCPT ); Fri, 9 Nov 2018 02:33:07 -0500 Received: from localhost (unknown [208.72.13.198]) (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 1A4EF20989; Thu, 8 Nov 2018 21:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714140; bh=YozpTyxTAAI4DvrPnwqTa5ixvcMmgBlpdwBQUvprVVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nbmnVIEaH/YAuDKG5lIMDReQeTDk6fFSL99tear6kJpseHzyR6VpDv2STBf0lWLcw BwXsqOdXq/qm68UTpimvQecqgbwk9PS4tRtox5Z/DWffXV5Mrd0J0i+GKldCmCsN/e lHg0gETPICPQsJavyiAiDqg7l9MduZr5BQXYlTIU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Ahern , Namhyung Kim , Jiri Olsa , Ingo Molnar , Jiri Olsa , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 3.18 074/144] perf machine: Fix __machine__findnew_thread() error path Date: Thu, 8 Nov 2018 13:50:45 -0800 Message-Id: <20181108215100.656296755@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215054.826084593@linuxfoundation.org> References: <20181108215054.826084593@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 260d819e3abdbdaa2b88fb983d1314f1b263f9e2 ] When thread__init_map_groups() fails, a new thread should be removed from the rbtree since it's gonna be freed. Also update last match cache only if the function succeeded. Reported-by: David Ahern Signed-off-by: Namhyung Kim Acked-by: Jiri Olsa Cc: David Ahern Cc: Ingo Molnar Cc: Jiri Olsa Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1420763892-15535-1-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/machine.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 34fc7c8672e4..84238a10c34b 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -389,7 +389,6 @@ static struct thread *__machine__findnew_thread(struct machine *machine, if (th != NULL) { rb_link_node(&th->rb_node, parent, p); rb_insert_color(&th->rb_node, &machine->threads); - machine->last_match = th; /* * We have to initialize map_groups separately @@ -400,9 +399,12 @@ static struct thread *__machine__findnew_thread(struct machine *machine, * leader and that would screwed the rb tree. */ if (thread__init_map_groups(th, machine)) { + rb_erase(&th->rb_node, &machine->threads); thread__delete(th); return NULL; } + + machine->last_match = th; } return th; -- 2.17.1