Received: by 10.213.65.68 with SMTP id h4csp1714233imn; Mon, 19 Mar 2018 11:14:00 -0700 (PDT) X-Google-Smtp-Source: AG47ELteIfuwXN/9Mp+dFzDu/ztzvKLZ4hGm9C9tfPg9c6Vb+bY4ZNRcv099fu2bYsea3ZP1/VWT X-Received: by 10.101.100.141 with SMTP id e13mr10022660pgv.333.1521483240101; Mon, 19 Mar 2018 11:14:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521483240; cv=none; d=google.com; s=arc-20160816; b=sRdEXpmK2li6qUuCz6/TdOo9P19FR7NkqLeTfkkZThYfwwZCPzDzarRsi8GR+z+lw8 9WiViWuj6HBjYN3SMPp6WgWBE4amGQH9ti+ZL2fW3yXCxfNahe5TUIKLLN34Fy/0k1lo F1Z3gUIfSOTgzZfxp9YAsa9IH8l8/eAFtzGXMFMj3NxMmBi7H3EENhjD/PNY71jwrNK/ lzWCrnFxBaRgduIsqzaiGe9BqBl8a/9lAfQ26XfZOmt829D5CKHcyovolONE+6SoQbF/ t7isjxAyD/t8YGIIgugn2CH+2rs3+6bs2EEcC7hnLLurNrGorBtWiLGCzYknQCFXwVoQ R8MQ== 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=/GXO6MoiLECYHjzaIi3VTdJ0AN5HOPrgDBmNYq3UnSI=; b=RT3NXfFClg2A7xLyn1K/VFHl+ajNLVtrIx9eld54ZSGrs2EIdxY2Edd1YlNf42dpU/ ojFY8vAU7eYYKsXrgPqPTbNH01SlJktBvFQEfhDXMN2D+VWp+S/HgJmQb+Kx0X5qRNoQ I3C9Up3DoWmtRCeeJByDTxNXSGgb4wzIR9TgV8Iq09NdlrbA9WxhU5T2al0uyEzc9/2I zBWka46SgkIa7E6HfAWHIaql3DnrrjJmnSve4U1flRImzgea3G0YICWdxz2x/w89eKqF lXA79QJxVYNl1wm/LhBLDP17sX6Cov50gdZmp3Ku2skG/S79zBMYQSKVGf1Wx9f8ugfn tbzg== 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 w11si304843pgt.391.2018.03.19.11.13.45; Mon, 19 Mar 2018 11:14:00 -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 S1030459AbeCSSMS (ORCPT + 99 others); Mon, 19 Mar 2018 14:12:18 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42646 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965597AbeCSSMM (ORCPT ); Mon, 19 Mar 2018 14:12:12 -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 3A5E911E9; Mon, 19 Mar 2018 18:12:11 +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.4 011/134] perf sort: Fix segfault with basic block cycles sort dimension Date: Mon, 19 Mar 2018 19:04:54 +0100 Message-Id: <20180319171850.727430371@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319171849.024066323@linuxfoundation.org> References: <20180319171849.024066323@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.4-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 @@ -604,6 +604,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; } @@ -611,6 +614,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,