The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Steven Price <steven.price@arm.com>
Cc: David Airlie <airlied@gmail.com>,
	Liviu Dudau <liviu.dudau@arm.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Simona Vetter <simona@ffwll.ch>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	Will Deacon <will@kernel.org>
Subject: Re: [PATCH] drm/panthor: Clean up FW version information display
Date: Wed, 5 Mar 2025 15:07:46 +0100	[thread overview]
Message-ID: <20250305150746.5b5dabba@collabora.com> (raw)
In-Reply-To: <20250213161248.1642392-1-steven.price@arm.com>

On Thu, 13 Feb 2025 16:12:48 +0000
Steven Price <steven.price@arm.com> 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 <will@kernel.org>
> Fixes: 9d443deb0441 ("drm/panthor: Display FW version information")
> Signed-off-by: Steven Price <steven.price@arm.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
> 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;
>  }


      parent reply	other threads:[~2025-03-05 14:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-13 16:12 [PATCH] drm/panthor: Clean up FW version information display Steven Price
2025-02-14 12:09 ` Will Deacon
2025-03-05 14:07 ` Boris Brezillon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250305150746.5b5dabba@collabora.com \
    --to=boris.brezillon@collabora.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=tzimmermann@suse.de \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox