From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (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 12C1C24397B for ; Wed, 5 Mar 2025 14:07:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741183677; cv=none; b=Ryc+Aacx2ij17VIeK0wYomYBqkfhYZ75jk4/LGVEYXjq8KKLLp1dfYvmutgxVqvNpka0nXp0aRQRqjpXLKB3+UyS63fs4f+GrvUXUonqf8rHegvEuWt3SO3XtO0qHNgUcudF1pGQkGkAt5BIYYbqdiUGbZa69t9Kf+hz+PaSw7g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741183677; c=relaxed/simple; bh=ylMxxZGDNV+12878qZV6Un+P+/ufktGGRokW3IlN2MA=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iJXauvpGkMi5JkXGjo47t3lN109IFQZBMy2kRb+ls3RSMJe4en99abOYY9og7BmWpZB8RmjsOPMnnaWiva8DdrhozCaIlBi79kZtUuiBUVtTq2p6qgo2R/yXkFUse8h7+7qnvZPOEHNTovXwFAZT7pk7wOeilxv+7ZI8NUADHbw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=J0oA6cBl; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="J0oA6cBl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1741183673; bh=ylMxxZGDNV+12878qZV6Un+P+/ufktGGRokW3IlN2MA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=J0oA6cBlaf/d4hoCk55aUhPODHTrYMUo5qTT2Ofwbd2qyAFMkkcm++olxv9J7hSne JaNtjoN1juPP3N6TuxEZEVuW/MyiPtfTNuuEc9TEFqeVQCXaKYY4EZ7/QHmbGn4xhc wS+8kTLsk/9Q4Sq3cfcSCjLtL68uwhvmPXQ1v8a5GLREJSd16g8hMXkG4MUT4x48S3 pomIFGhtpF5rpDpS2nmUZZYKefloiX5jcdeNgeMInqfpeQr/JwjK4IGYi6wl2A1h9E aClCfJybIGHrffuXF95yN5H1cy4m1PC+ka1jM7LxOauh0R/t7mBovjKRUyAGCCJBjf w18YPG7vmb0bw== Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id B37FB17E0599; Wed, 5 Mar 2025 15:07:52 +0100 (CET) Date: Wed, 5 Mar 2025 15:07:46 +0100 From: Boris Brezillon To: Steven Price Cc: David Airlie , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Simona Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Will Deacon Subject: Re: [PATCH] drm/panthor: Clean up FW version information display Message-ID: <20250305150746.5b5dabba@collabora.com> In-Reply-To: <20250213161248.1642392-1-steven.price@arm.com> References: <20250213161248.1642392-1-steven.price@arm.com> Organization: Collabora X-Mailer: Claws Mail 4.3.0 (GTK 3.24.43; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 13 Feb 2025 16:12:48 +0000 Steven Price wrote: > 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 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_device *ptdev, > u32 ehdr) > { > struct panthor_fw_build_info_hdr hdr; > - char header[9]; > - const char git_sha_header[sizeof(header)] = "git_sha: "; > + const char git_sha_header[] = "git_sha: "; > + const int header_len = sizeof(git_sha_header) - 1; > int ret; > > ret = panthor_fw_binary_iter_read(ptdev, iter, &hdr, sizeof(hdr)); > @@ -651,8 +651,7 @@ static int panthor_fw_read_build_info(struct panthor_device *ptdev, > return 0; > } > > - 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_device *ptdev, > } > > 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); > > return 0; > }