From: Greg KH <gregkh@linuxfoundation.org>
To: Sumera Priyadarsini <sylphrenadin@gmail.com>
Cc: airlied@linux.ie, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, melissa.srw@gmail.com,
outreachy-kernel@googlegroups.com, amd-gfx@lists.freedesktop.org,
daniel@ffwll.ch, alexander.deucher@amd.com,
christian.koenig@amd.com, linux-media@vger.kernel.org
Subject: Re: [Outreachy kernel] [PATCH 4/5] gpu: drm: amdgpu: Replace snprintf() with sysfs_emit()
Date: Thu, 22 Oct 2020 15:54:55 +0200 [thread overview]
Message-ID: <20201022135455.GA1788090@kroah.com> (raw)
In-Reply-To: <f6107f3e467f1906abdcc33d35f13cf54f7e5a96.1603371258.git.sylphrenadin@gmail.com>
On Thu, Oct 22, 2020 at 07:17:56PM +0530, Sumera Priyadarsini wrote:
> Using snprintf() for show() methods holds the risk of buffer overrun
> as snprintf() does not know the PAGE_SIZE maximum of the temporary
> buffer used to output sysfs content.
>
> Modify amdgpu_psp.c to use sysfs_emit() instead which knows the
> size of the temporary buffer.
>
> Issue found with Coccinelle.
>
> Signed-off-by: Sumera Priyadarsini <sylphrenadin@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index d6c38e24f130..4d1d1e1b005d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -2621,7 +2621,7 @@ static ssize_t psp_usbc_pd_fw_sysfs_read(struct device *dev,
> return ret;
> }
>
> - return snprintf(buf, PAGE_SIZE, "%x\n", fw_ver);
> + return sysfs_emit(buf, PAGE_SIZE, "%x\n", fw_ver);
Did you build this code? I don't think it is correct...
thanks,
greg k-h
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <gregkh@linuxfoundation.org>
To: Sumera Priyadarsini <sylphrenadin@gmail.com>
Cc: dri-devel@lists.freedesktop.org,
outreachy-kernel@googlegroups.com, alexander.deucher@amd.com,
christian.koenig@amd.com, airlied@linux.ie, daniel@ffwll.ch,
melissa.srw@gmail.com, linux-media@vger.kernel.org,
amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [Outreachy kernel] [PATCH 4/5] gpu: drm: amdgpu: Replace snprintf() with sysfs_emit()
Date: Thu, 22 Oct 2020 15:54:55 +0200 [thread overview]
Message-ID: <20201022135455.GA1788090@kroah.com> (raw)
In-Reply-To: <f6107f3e467f1906abdcc33d35f13cf54f7e5a96.1603371258.git.sylphrenadin@gmail.com>
On Thu, Oct 22, 2020 at 07:17:56PM +0530, Sumera Priyadarsini wrote:
> Using snprintf() for show() methods holds the risk of buffer overrun
> as snprintf() does not know the PAGE_SIZE maximum of the temporary
> buffer used to output sysfs content.
>
> Modify amdgpu_psp.c to use sysfs_emit() instead which knows the
> size of the temporary buffer.
>
> Issue found with Coccinelle.
>
> Signed-off-by: Sumera Priyadarsini <sylphrenadin@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index d6c38e24f130..4d1d1e1b005d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -2621,7 +2621,7 @@ static ssize_t psp_usbc_pd_fw_sysfs_read(struct device *dev,
> return ret;
> }
>
> - return snprintf(buf, PAGE_SIZE, "%x\n", fw_ver);
> + return sysfs_emit(buf, PAGE_SIZE, "%x\n", fw_ver);
Did you build this code? I don't think it is correct...
thanks,
greg k-h
WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <gregkh@linuxfoundation.org>
To: Sumera Priyadarsini <sylphrenadin@gmail.com>
Cc: airlied@linux.ie, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, melissa.srw@gmail.com,
outreachy-kernel@googlegroups.com, amd-gfx@lists.freedesktop.org,
alexander.deucher@amd.com, christian.koenig@amd.com,
linux-media@vger.kernel.org
Subject: Re: [Outreachy kernel] [PATCH 4/5] gpu: drm: amdgpu: Replace snprintf() with sysfs_emit()
Date: Thu, 22 Oct 2020 15:54:55 +0200 [thread overview]
Message-ID: <20201022135455.GA1788090@kroah.com> (raw)
In-Reply-To: <f6107f3e467f1906abdcc33d35f13cf54f7e5a96.1603371258.git.sylphrenadin@gmail.com>
On Thu, Oct 22, 2020 at 07:17:56PM +0530, Sumera Priyadarsini wrote:
> Using snprintf() for show() methods holds the risk of buffer overrun
> as snprintf() does not know the PAGE_SIZE maximum of the temporary
> buffer used to output sysfs content.
>
> Modify amdgpu_psp.c to use sysfs_emit() instead which knows the
> size of the temporary buffer.
>
> Issue found with Coccinelle.
>
> Signed-off-by: Sumera Priyadarsini <sylphrenadin@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index d6c38e24f130..4d1d1e1b005d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -2621,7 +2621,7 @@ static ssize_t psp_usbc_pd_fw_sysfs_read(struct device *dev,
> return ret;
> }
>
> - return snprintf(buf, PAGE_SIZE, "%x\n", fw_ver);
> + return sysfs_emit(buf, PAGE_SIZE, "%x\n", fw_ver);
Did you build this code? I don't think it is correct...
thanks,
greg k-h
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-10-22 13:59 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-22 13:31 [Outreachy kernel][PATCH 0/5] drm/amdgpu: Replace snprintf() with sysfs_emit Sumera Priyadarsini
2020-10-22 13:37 ` Sumera Priyadarsini
2020-10-22 13:37 ` Sumera Priyadarsini
2020-10-22 13:37 ` Sumera Priyadarsini
2020-10-22 13:37 ` Greg KH
2020-10-22 13:49 ` Vaishali Thakkar
2020-10-22 14:12 ` Sumera Priyadarsini
2020-10-22 14:17 ` Vaishali Thakkar
2020-10-22 13:40 ` [PATCH 1/5] gpu: drm: amdgpu: Replace snprintf() with sysfs_emit() Sumera Priyadarsini
2020-10-22 13:40 ` Sumera Priyadarsini
2020-10-22 13:40 ` Sumera Priyadarsini
2020-10-22 13:43 ` [PATCH 2/5] " Sumera Priyadarsini
2020-10-22 13:43 ` Sumera Priyadarsini
2020-10-22 13:43 ` Sumera Priyadarsini
2020-10-22 13:47 ` [PATCH 3/5] " Sumera Priyadarsini
2020-10-22 13:47 ` Sumera Priyadarsini
2020-10-22 13:47 ` Sumera Priyadarsini
2020-10-22 13:47 ` [PATCH 4/5] " Sumera Priyadarsini
2020-10-22 13:47 ` Sumera Priyadarsini
2020-10-22 13:47 ` Sumera Priyadarsini
2020-10-22 13:54 ` Greg KH [this message]
2020-10-22 13:54 ` [Outreachy kernel] " Greg KH
2020-10-22 13:54 ` Greg KH
2020-10-22 21:40 ` Sumera Priyadarsini
2020-10-22 21:40 ` Sumera Priyadarsini
2020-10-22 21:40 ` Sumera Priyadarsini
2020-10-22 13:49 ` [PATCH 5/5] " Sumera Priyadarsini
2020-10-22 13:49 ` Sumera Priyadarsini
2020-10-22 13:49 ` Sumera Priyadarsini
2020-10-22 14:13 ` [Outreachy kernel][PATCH 0/5] drm/amdgpu: Replace snprintf() with sysfs_emit Daniel Vetter
2020-10-22 14:13 ` Daniel Vetter
2020-10-22 14:13 ` Daniel Vetter
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=20201022135455.GA1788090@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=melissa.srw@gmail.com \
--cc=outreachy-kernel@googlegroups.com \
--cc=sylphrenadin@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.