Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2389571lqp; Sun, 24 Mar 2024 17:17:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTxOHTB41uhUAuY0TF8K1T16Pq96pxhYBlB03wsUIrGq0vKEC+mgzx0Znc6Q0W9JMGUDm9V5xkPvQ2FQuYkiqoPGvuDJb+prwIGtOSiw== X-Google-Smtp-Source: AGHT+IE6/GhvW+1nr2goragiikAcot/gWx1EG1/QyWtprXYBJG8Kd1pKn1Hlz8+zyEfHyaOhMcD6 X-Received: by 2002:a17:903:40c2:b0:1e0:1174:6360 with SMTP id t2-20020a17090340c200b001e011746360mr6988232pld.14.1711325824768; Sun, 24 Mar 2024 17:17:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711325824; cv=pass; d=google.com; s=arc-20160816; b=ldJ5IpMcnQjsQGxYTiY1nEaXb6JEbQ3LLM0Jwh3l6Dj1gc7XhJS6eiTsGIemcY0ReP XYcv48xrMNXQ4wwC3jrKbU+kDaejSQM/HX/3ZrUoGRBozZxn/H0ahNjE7JFzmWBiftJL HtVniUrSu286WuC5kJY51UutlufiFSNZhlq+pyNAQbnXJRo67dElsxepxm0X4FpoOyU+ YfztYYQJk/4MdF+31mXA6aOBEsTRa2ZYfmZCEw4k5XAs3u2/JC/jN47/TFK/5RBZgZUM exjFnKDt77voLgLSLhKXdeQhDZwmTJg2isXP6eMAvD2OMet/qiyl9WTTTs+5WA8me9yI n+MA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=sGdLZ+ipd+Ymj6goV92Ec3nhvvjAuqvntQkX3ut8lLI=; fh=Fc1ZoZ1vTp7JxUZvOdwuMH0+wZ16tuMxS8CO2DXLMx0=; b=muPHWaqabp8w62rNLuwcrbPaBex1iugRPoxxsfWGoBhy/s8zKiBLr/9dpUXb3TXfJa ZNNc2nLe/NXNQTWFkuCdWTQuuxl4/RY6v1tpivv8+qzTNcDR86yAH8uPvHt0YvSlaj46 OVuaQof20ocbRfss8UOPK6zSy/BRZNrnQ4+fGVC6t1cB/rWp63fhG+h30evynXUxt3Iw 3LxAx6iaX7njmANMx33SNxTmSQgXVfIGJapDWYJ/PrQRi30FoaYcPvyHtj7A6d7ff9dM d8hOybk9EMDmLf0pdZmIqq5ltVuZn+ofNjDW6igZhHii0K/jfzkDSUXskLCc6o4cS7AE m/Eg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OZb1zh2R; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113316-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id a8-20020a170902900800b001dee64d24ebsi3942067plp.611.2024.03.24.17.17.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:17:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OZb1zh2R; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113316-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 E4F28B2100B for ; Mon, 25 Mar 2024 00:08:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE5A9193FA5; Sun, 24 Mar 2024 22:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OZb1zh2R" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D171519388E; Sun, 24 Mar 2024 22:41:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320117; cv=none; b=I2dOsbECQjaLlf/2Azmywc3SiqECA0dLmfQzLwtbouPO+LNv+3xuGZOvIJEg/ytfnFPeN+Ai76tcAzC+Thj+Eo+jU5zIQmfiR+FnGIAXqMhO00FB4mCSQE2WjmeSx8QhHidMIGie/rJ/UhViqUOMnoqvN+vQs95jKYd45+c/UVA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320117; c=relaxed/simple; bh=gAqGlDlzDquxOD2+ZQhfbxc9Xuv12uclhQjuVIseTAE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t2szdohxG1jE5zgp7PO9YFd9fIF7kDkqfP+fh+bADpncSs/tmfZQA/58oAgZgeXyNza1NZzwL555nG7skQoLZvyetBRelvappNM8IEDjJqROr5jpFfFHuPj6ST+HSOqtfvyGvP2EXOCJTUtM6dIvQRq2P2cyCwhy4Tw0ba8bYm4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OZb1zh2R; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66C28C433F1; Sun, 24 Mar 2024 22:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320117; bh=gAqGlDlzDquxOD2+ZQhfbxc9Xuv12uclhQjuVIseTAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZb1zh2RbJMJzfCcDjhw0Qs0qSBdvbHsavrDhWSwbDwg4TkA1YGOl94Hqac4Wm+ia xc2eYmf/BCMU62/6sjpxkKU3BpCzNRZb74as9Uz2CkaVVlTk2X6FuJjUspce7eCrVt htqojgpxWszpOeIw5/MEzHeWrr5bsWELEnUJhx/T4W+Se6tBu1rxbTurVN7lXjPKoz Y8vB4ULTYQ7o4p3EtqYNXjbH42Ma/KTr8eggqvs5BIg9CYphlPilt3oD6HU0MR/ehh XosFGDC+7y/TW+XtEMtKa6miWA+HNCuUSVjJPCvhG51W4xoR2yhrLGfKHE/3PjhHsn nMtGBVK4sbJlQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ian Rogers , Kan Liang , K Prateek Nayak , James Clark , Kaige Ye , John Garry , Namhyung Kim , Sasha Levin Subject: [PATCH 6.8 425/715] perf stat: Avoid metric-only segv Date: Sun, 24 Mar 2024 18:30:04 -0400 Message-ID: <20240324223455.1342824-426-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Ian Rogers [ Upstream commit 2543947c77e0e224bda86b4e7220c2f6714da463 ] 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 Reviewed-by: Kan Liang Cc: K Prateek Nayak Cc: James Clark Cc: Kaige Ye Cc: John Garry Signed-off-by: Namhyung Kim Link: https://lore.kernel.org/r/20240209204947.3873294-4-irogers@google.com Signed-off-by: Sasha Levin --- 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 8c61f8627ebc9..b7d00a538d703 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