Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1187720rdb; Fri, 9 Feb 2024 13:08:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IG8ahMBFv1qMopLC6HmlHfEPw58zvKyoOEvYI5q840z8yPjdQCO+fAfC3fAud28E6WdngJd X-Received: by 2002:a05:6602:71a:b0:7c3:ec32:fb8f with SMTP id f26-20020a056602071a00b007c3ec32fb8fmr691497iox.1.1707512905545; Fri, 09 Feb 2024 13:08:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707512905; cv=pass; d=google.com; s=arc-20160816; b=B/ANySTN2g5RLqqTVYy3dFFqH6lkxMxAOrendZCB69nrWiY4eTwt7oECBiT5QwGos4 aB3PJtqeMONgRXntEBi1HV5suxGTUVN0q70eL/0l2AqWmgLtn9AiZGfpfusds8eVWp99 C5pSiCmGi73RuUsrsvjanFb1+0EvtMag/l3mIXNLsEHioAxRA0XXIp8oyRPrJtm9rc75 N0NlmX/cAxdaOJ+5BmAU7qIT8nCUc59P1i+uekN4IY1ye+oZ5hUgrc9Kt09lgmPLPqIY emuqzpB06TwYAMMTXwHA+6W2ud/oMSzCLctXcp0DI93RmyoQcp7cnUbrJe3iguPWDV2u nwpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=oBdjorgQB0gt1zgRALPto7TpPrhqP+5PDX20bu5pfxU=; fh=SVc10RbzUMc5sDTu8t2lHK4mvGw+u2ZPPlnr/ytjFWQ=; b=nTemEUmMN14BK6/qccut5/Di12yXoC5pVUaSoVT3twzBEPN/pMcj1ayttno6FeUHCA YuQlTlrdCZsT1rxZU5m3iBJ7aSD9Rjb9Xzw/YNuWNoY2scNiR5C1ICdPA9dpnHnA7a54 L0sLgAKvGzJZ3R1j2Wap8QvKg5B7a8V31Lluyjp6u+mAmu7q3u2US6RVVTCS14iTWnH+ gJ6aCapxVR3lNDWvJvAsKvM5OTGvEqlYGJyPTv3lLCpunLlnJW+y3mqPS4Jkf9nlnrlZ /DY8lTXVNj9UBenQ+15cJ+tH7GKIr489CmCIGOZr/9h88wC1O8GGFPwKDWWDRBMyZ1ol ASfw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=LewBizmV; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-59964-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59964-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCV4M/8HUPtbhWYNtASG+/FDF1NgI4++avSmBAQ3S+XD866NRJGIowY+0yfLPCJbFF64DflefVCwEFcVIg4PioToZP2ZyJESasyIHP+/OA== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id cb1-20020a056a02070100b005dc43104eefsi2496144pgb.104.2024.02.09.13.08.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 13:08:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59964-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=LewBizmV; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-59964-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59964-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 61DC9B28267 for ; Fri, 9 Feb 2024 20:51:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80D4B199D6; Fri, 9 Feb 2024 20:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LewBizmV" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DF9C15485 for ; Fri, 9 Feb 2024 20:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707511818; cv=none; b=R2vAdsqLj05iMTmHGh2O9RBucQuswittJKDaiMxm9ztxlKKVA7lbbxGbVtGvt2+ZE0BSIHPHK6aCbM3X5P0D+Zu88HtW+rZBWngIv3RgOGZFZcrh80AGnCNka4Xeb8cHx+QfQKFu3pGmKQgs8qXgRlfuzIBYgUUL2H+0azJ09hE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707511818; c=relaxed/simple; bh=FN1xH7txpWYfGe8oXzu7wp0Df0lMgRHZJT67LPNIglU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ZMfOa6UcHNfYV87tymwYchQmZZ5KMWqE+QqVy4YLRwgk7LH4JLkBoLxytg9xW0GdOgG+BYVsOdEE1eDR5wO0sJdTzuzAekCw3pC5F8HwjhZ3ri1Em22clTa/TISLJwQnRLrm6vdkk3/e8+XSb0r5nZ5UlknNG4zfAu9VmSRMsAc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=LewBizmV; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6b269b172so3194833276.1 for ; Fri, 09 Feb 2024 12:50:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707511816; x=1708116616; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=oBdjorgQB0gt1zgRALPto7TpPrhqP+5PDX20bu5pfxU=; b=LewBizmV3f85bnm5XnNTMrsb6wd4bKnUbo2UeCWJCHCqbmnGvOxlAZ15l0DIYFxFl/ CPBIGBzRno0n6DJz+9eFK6I02sBVwueMzR0I3qH59KT54tFalKPz31ylLZm4jqVcFW8S 6VOB+oEHsP30+eJAFq0L3QePhh2nn1MngvbtHS6ddGzK3NXW3i3E9fUiHq3iPsmokuwk uLLM+TF7F03qEPMWNrY6S+JWezAOGxj6Qf+T6wyVBQQzPtUg4mu4soULBTGUPNax41qx eRhl+g86T24DbNfaqKv6E1uv4YIByunJdfzT5BuZ1GjlZP9xqsWopZyCvGidgixHVCZw Bauw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707511816; x=1708116616; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oBdjorgQB0gt1zgRALPto7TpPrhqP+5PDX20bu5pfxU=; b=dgigybi3ipi1tlbCrcsKsSJbuYseyxNNn8ybUdBo68Gg4eFRVa2Wp3lo86EhKTC8TC wybWuK61ymgaRVjL+SPwa6/lNyh259R92b5n6SSSk5TIdjTwDT59Aa+z2fc5wlMPFN12 Km21FQ6rNpjHYOIIPHejSmnZRz6gl8Ztj5GfZjBym6LykcAskS6Elb73b5XaGsbTgUcY qbFXIoL4mWNpwI+E4VHMYJPa1m23wPbm2Ce28sB/RDWMExOH9e9bTjKdThqO8Wl7TSNN hilq0ZMy0FsuuYUGQ9cnlytpLY74Ipc9qyhm5hvqIS46D8MyTckCwo8iEWoH38Yx5HUI ou1Q== X-Gm-Message-State: AOJu0YxrZ8BHgatirE/Gh3mNEgRO8aBYTVViHNmC6N4SkXvp3w/qc5Tk ZM+d6Ts5EfJu1GPx5CPbkvRutSBcqDz1wVGeRyUKCmIZz1ZASsQzbmpeFLFVLb591h8pQKxVhhg 670VPFQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:877:241d:8c35:1c5b]) (user=irogers job=sendgmr) by 2002:a25:ae03:0:b0:dc7:463a:46d2 with SMTP id a3-20020a25ae03000000b00dc7463a46d2mr421048ybj.0.1707511816316; Fri, 09 Feb 2024 12:50:16 -0800 (PST) Date: Fri, 9 Feb 2024 12:49:46 -0800 In-Reply-To: <20240209204947.3873294-1-irogers@google.com> Message-Id: <20240209204947.3873294-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240209204947.3873294-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Subject: [PATCH v1 3/4] perf stat: Avoid metric-only segv From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , James Clark , K Prateek Nayak , Kaige Ye , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Cycles is recognized as part of a hard coded metric in stat-shadow.c, it may call print_metric_only with a NULL fmt string leading to a segfault. Handle the NULL fmt explicitly. Fixes: 088519f318be ("perf stat: Move the display functions to stat-display.c") Signed-off-by: Ian Rogers --- Note, the fixes tag is to a refactor that moved the function. The bug existed before this. --- tools/perf/util/stat-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 8c61f8627ebc..b7d00a538d70 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -560,7 +560,7 @@ static void print_metric_only(struct perf_stat_config *config, if (color) mlen += strlen(color) + sizeof(PERF_COLOR_RESET) - 1; - color_snprintf(str, sizeof(str), color ?: "", fmt, val); + color_snprintf(str, sizeof(str), color ?: "", fmt ?: "", val); fprintf(out, "%*s ", mlen, str); os->first = false; } -- 2.43.0.687.g38aa6559b0-goog