From nobody Thu Dec 18 20:22:31 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4868202F72 for ; Thu, 13 Feb 2025 16:13:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739463212; cv=none; b=XkhW+B1Oxy1P/cDtCaOL3JWdNdeb3eyHcZrKrT4bklAai9aXnr5TtvKmLSvIAZbx86MLJiVM9xjd/tggFBv+66TKBIfeILqEOflHq+pcWFaX5M1u10UEDk7r2OlYISweNwxUzb90F7BpxDKoHfY2apukDX4NU+plzIgQr5+q73s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739463212; c=relaxed/simple; bh=MJNeQypHksqBGTQi1UN/30/JOXYdU1SM+UCWIlibTlk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=GglNKmr8mDX1GJ1b36RtHNN4IHWM/62TShNW5M88di6/B00FjxGBlJZEdyWCjn+trxzNebQ2EYqC4a/4JiA2pQfJA0BlSh1OQPXJ7+edl63k+j/NmCQ0CiSh2gv3l7lEkIZLo5Lcz7BpOcflhLH6AWMCncUMuvpTLFDaiz1HCZI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 598D21756; Thu, 13 Feb 2025 08:13:50 -0800 (PST) Received: from e112269-lin.cambridge.arm.com (e112269-lin.cambridge.arm.com [10.1.194.64]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CE70B3F6A8; Thu, 13 Feb 2025 08:13:27 -0800 (PST) From: Steven Price To: Boris Brezillon , David Airlie , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Simona Vetter , Thomas Zimmermann Cc: Steven Price , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Will Deacon Subject: [PATCH] drm/panthor: Clean up FW version information display Date: Thu, 13 Feb 2025 16:12:48 +0000 Message-Id: <20250213161248.1642392-1-steven.price@arm.com> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Assigning a string to an array which is too small to include the NUL byte at the end causes a warning on some compilers. But this function also has some other oddities like the 'header' array which is only ever used within sizeof(). Tidy up the function by removing the 'header' array, allow the NUL byte to be present in git_sha_header, and calculate the length directly from git_sha_header. Reported-by: Will Deacon Fixes: 9d443deb0441 ("drm/panthor: Display FW version information") Signed-off-by: Steven Price Acked-by: Will Deacon Reviewed-by: Boris Brezillon --- Note that there should be no functional change from this patch. --- drivers/gpu/drm/panthor/panthor_fw.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor= /panthor_fw.c index 4a9c4afa9ad7..645fc6d2e63b 100644 --- a/drivers/gpu/drm/panthor/panthor_fw.c +++ b/drivers/gpu/drm/panthor/panthor_fw.c @@ -636,8 +636,8 @@ static int panthor_fw_read_build_info(struct panthor_de= vice *ptdev, u32 ehdr) { struct panthor_fw_build_info_hdr hdr; - char header[9]; - const char git_sha_header[sizeof(header)] =3D "git_sha: "; + const char git_sha_header[] =3D "git_sha: "; + const int header_len =3D sizeof(git_sha_header) - 1; int ret; =20 ret =3D panthor_fw_binary_iter_read(ptdev, iter, &hdr, sizeof(hdr)); @@ -651,8 +651,7 @@ static int panthor_fw_read_build_info(struct panthor_de= vice *ptdev, return 0; } =20 - if (memcmp(git_sha_header, fw->data + hdr.meta_start, - sizeof(git_sha_header))) { + if (memcmp(git_sha_header, fw->data + hdr.meta_start, header_len)) { /* Not the expected header, this isn't metadata we understand */ return 0; } @@ -665,7 +664,7 @@ static int panthor_fw_read_build_info(struct panthor_de= vice *ptdev, } =20 drm_info(&ptdev->base, "Firmware git sha: %s\n", - fw->data + hdr.meta_start + sizeof(git_sha_header)); + fw->data + hdr.meta_start + header_len); =20 return 0; } --=20 2.39.5