From nobody Fri Dec 19 22:05:33 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7EE1CD4859 for ; Fri, 22 Sep 2023 19:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233916AbjIVT1n (ORCPT ); Fri, 22 Sep 2023 15:27:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233692AbjIVT1i (ORCPT ); Fri, 22 Sep 2023 15:27:38 -0400 Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86317AC for ; Fri, 22 Sep 2023 12:27:30 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id jloFqD9PsGlzojloFq0RyT; Fri, 22 Sep 2023 21:27:28 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1695410848; bh=XEqKkQdd+1AGqY7DppYqYg8hkwbZVqfTt1fDBwsytHo=; h=From:To:Cc:Subject:Date; b=tzuTLQNT2FcvHWUhvK7u8I5xvd2KA5IRJCU1xjcCBN4l14vbvTpn2YO5G3N99N/iJ hBcGEeW26CUo24OMz22rm7R7kHw6+L9UiNn9p1RihPMY9pIFn50z7GsjgWYTCKf8hq Xk2ml88ep4HJsD9wm1TI+fpSCN3ITNY6nXlOcQvmGLuQBji6qGheyUzJs25Bc9c+rP 6a61QFX1qkWHe5OzhUMSVPdemOGVORUV8YmY6sHZrkLKy+lnBZ72S5fJe4/UxuG34e p6B4dixT6ScxQcx+gFHVwUxGEovC9xubtfVh4LnikubTrm4NFY/d7Plxm0r5/+1EwQ Jm27Pr7yM5EWQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 22 Sep 2023 21:27:28 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Lijo Lazar , Mario Limonciello Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/amd: Fix the size of a buffer in amdgpu_vcn_idle_work_handler() Date: Fri, 22 Sep 2023 21:27:25 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to be sure that fw_name is not truncated, this buffer should be at least 41 bytes long. Let the compiler compute the correct length by itself. When building with W=3D1, this fixes the following warnings: drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c: In function =E2=80=98amdgpu_vcn_= early_init=E2=80=99: drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c:95:58: error: =E2=80=98snprintf= =E2=80=99 output may be truncated before the last format character [-Werror= =3Dformat-truncation=3D] 95 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode= _prefix); | ^ drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c:95:9: note: =E2=80=98snprintf=E2= =80=99 output between 12 and 41 bytes into a destination of size 40 95 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode= _prefix); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~ Fixes: 69939009bde7 ("drm/amd: Load VCN microcode during early_init") Signed-off-by: Christophe JAILLET --- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_vcn.c index c93f3a4c0e31..f8cd55a0d1f0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c @@ -88,7 +88,7 @@ static void amdgpu_vcn_idle_work_handler(struct work_stru= ct *work); int amdgpu_vcn_early_init(struct amdgpu_device *adev) { char ucode_prefix[30]; - char fw_name[40]; + char fw_name[sizeof(ucode_prefix) + sizeof("amdgpu/.bin") - 1]; int r; =20 amdgpu_ucode_ip_version_decode(adev, UVD_HWIP, ucode_prefix, sizeof(ucode= _prefix)); --=20 2.34.1