Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753062AbdHRNpI (ORCPT ); Fri, 18 Aug 2017 09:45:08 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:55384 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752732AbdHRNPq (ORCPT ); Fri, 18 Aug 2017 09:15:46 -0400 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "David Carrillo-Cisneros" , "Masami Hiramatsu" , "Andrew Vagin" , "Arnaldo Carvalho de Melo" , "Andi Kleen" , "Wang Nan" , "Stephane Eranian" , "Paul Turner" , "Alexander Shishkin" , "Simon Que" , "Jiri Olsa" , "Peter Zijlstra" , "He Kuang" Date: Fri, 18 Aug 2017 14:13:20 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 040/134] perf inject: Don't proceed if perf_session__process_event() fails In-Reply-To: X-SA-Exim-Connect-IP: 82.70.136.246 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1823 Lines: 51 3.16.47-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: David Carrillo-Cisneros commit bb8d521f77f3e68a713456b7fb1e99f52ff3342c upstream. All paths following perf_session__process_event() in __cmd_inject() are useless if __cmd_inject() is to fail, some depend on a correct session->evlist. First commit to add code that depends on session->evlist without checking error was commmit e558a5bd8b ("perf inject: Work with files"). It has grown since then. Change __cmd_inject() to fail immediately after perf_session__process_event() fails. Signed-off-by: David Carrillo-Cisneros Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Andrew Vagin Cc: He Kuang Cc: Masami Hiramatsu Cc: Paul Turner Cc: Peter Zijlstra Cc: Simon Que Cc: Stephane Eranian Cc: Wang Nan Fixes: e558a5bd8b74 ("perf inject: Work with files") Link: http://lkml.kernel.org/r/20170410201432.24807-2-davidcc@google.com Signed-off-by: Arnaldo Carvalho de Melo [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- tools/perf/builtin-inject.c | 2 ++ 1 file changed, 2 insertions(+) --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -387,6 +387,8 @@ static int __cmd_inject(struct perf_inje lseek(file_out->fd, session->header.data_offset, SEEK_SET); ret = perf_session__process_events(session, &inject->tool); + if (ret) + return ret; if (!file_out->is_pipe) { session->header.data_size = inject->bytes_written;