Received: by 10.213.65.68 with SMTP id h4csp1776208imn; Mon, 19 Mar 2018 12:59:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELsEtzstIzQr8GXT4pa66ayX5pGsIDfZ/nrQb3miMNdHUVpdLCQ2/6jZL1QMZAPVt6F6crEc X-Received: by 10.99.9.132 with SMTP id 126mr10006802pgj.446.1521489543669; Mon, 19 Mar 2018 12:59:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521489543; cv=none; d=google.com; s=arc-20160816; b=QrTVD4JYTzjBMeFI2ncQQ012fAzXuxoaswx4hEkOgxGs6eDMV08KcUDvZyoao04W1D JRl2aEY6P21/1AqZl1uOS6gop9cA1dYn6Bg978gsnO3X3CVzr/DnfDO3DOSdyuLrekyb oiYbFdEVEUgw756LaCvzGX3Dbca2qC5w7fNosHBHYoiIxvhdakXVQxBw+Z3T30I7OL6Y jGx0zzMfmA0uTQXKzdDyM1pfjRLtpsQe4l4+hF8UUJ3elT0Kp1EBUzMHTCutB+UG5jqs 1xP6EhGX2kHelb0j5WqqIsMDl6rVnJefKvV7PJWArsdGHmDrlL08VZzcvsPcDwQTw47a dzKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=f+S2Sf46/EQkp/+YP1ipMTfy7UWW6f6k3ari7x3JtwI=; b=G8+8WMdJ7bUrWu5nDIxXfevDA5/mH+TJqdjmN5AWbgHVMmO+C62pnipDXFZnHPSufC RlOwif9m4YLgWAuOLt2gDfhyPKMnsw1F7ofLWdFeX8fXmd4TgxcHtnxz10lLLE0f5APq Agzcc2jXwtdthrLynedfIiiY54dxPxemZRNs5/ZcatuacChjYDfsth2t0jC4gUkIA94K OwlZj1U5Zmpg5akveAVXZFe2A4026lTBqaGAgDZGoPhmEs0Z83hPxa3fwSdVfdIua+d4 lVWrX4L/XCzaIbb6ixhwWErzeb33OblbfTUcnzplSaETZ78a0ACKLhg7aqMoiJbBMAle Dyew== ARC-Authentication-Results: i=1; mx.google.com; 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 p11-v6si595570pli.599.2018.03.19.12.58.49; Mon, 19 Mar 2018 12:59:03 -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; 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 S1030903AbeCSSSy (ORCPT + 99 others); Mon, 19 Mar 2018 14:18:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46664 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030852AbeCSSSr (ORCPT ); Mon, 19 Mar 2018 14:18:47 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 55A8D1088; Mon, 19 Mar 2018 18:18:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Changbin Du , Arnaldo Carvalho de Melo , Andi Kleen , Peter Zijlstra , Sasha Levin Subject: [PATCH 4.9 021/241] perf sort: Fix segfault with basic block cycles sort dimension Date: Mon, 19 Mar 2018 19:04:46 +0100 Message-Id: <20180319180752.044999756@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Changbin Du [ Upstream commit 4b0b3aa6a2756e6115fdf275c521e4552a7082f3 ] Skip the sample which doesn't have branch_info to avoid segmentation fault: The fault can be reproduced by: perf record -a perf report -F cycles Signed-off-by: Changbin Du Tested-by: Arnaldo Carvalho de Melo Cc: Andi Kleen Cc: Peter Zijlstra Fixes: 0e332f033a82 ("perf tools: Add support for cycles, weight branch_info field") Link: http://lkml.kernel.org/r/20170313083148.23568-1-changbin.du@intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/sort.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -846,6 +846,9 @@ static int hist_entry__mispredict_snprin static int64_t sort__cycles_cmp(struct hist_entry *left, struct hist_entry *right) { + if (!left->branch_info || !right->branch_info) + return cmp_null(left->branch_info, right->branch_info); + return left->branch_info->flags.cycles - right->branch_info->flags.cycles; } @@ -853,6 +856,8 @@ sort__cycles_cmp(struct hist_entry *left static int hist_entry__cycles_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) { + if (!he->branch_info) + return scnprintf(bf, size, "%-.*s", width, "N/A"); if (he->branch_info->flags.cycles == 0) return repsep_snprintf(bf, size, "%-*s", width, "-"); return repsep_snprintf(bf, size, "%-*hd", width,