<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 22, 2020 at 7:24 PM Greg KH <<a href="mailto:gregkh@linuxfoundation.org">gregkh@linuxfoundation.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Oct 22, 2020 at 07:17:56PM +0530, Sumera Priyadarsini wrote:<br>
> Using snprintf() for show() methods holds the risk of buffer overrun<br>
> as snprintf() does not know the PAGE_SIZE maximum of the temporary<br>
> buffer used to output sysfs content.<br>
> <br>
> Modify amdgpu_psp.c to use sysfs_emit() instead which knows the<br>
> size of the temporary buffer.<br>
> <br>
> Issue found with Coccinelle.<br>
> <br>
> Signed-off-by: Sumera Priyadarsini <<a href="mailto:sylphrenadin@gmail.com" target="_blank">sylphrenadin@gmail.com</a>><br>
> ---<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +-<br>
> 1 file changed, 1 insertion(+), 1 deletion(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
> index d6c38e24f130..4d1d1e1b005d 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
> @@ -2621,7 +2621,7 @@ static ssize_t psp_usbc_pd_fw_sysfs_read(struct device *dev,<br>
> return ret;<br>
> }<br>
> <br>
> - return snprintf(buf, PAGE_SIZE, "%x\n", fw_ver);<br>
> + return sysfs_emit(buf, PAGE_SIZE, "%x\n", fw_ver);<br>
<br>
Did you build this code? I don't think it is correct...<br></blockquote><div><br></div><div>Yes, you are right. I compiled all of them again separately. I had based them off the usual drm tree<br></div><div>but that is wrong because sysfs_emit has been added only in the 5.10. I will send a v2 with the proper</div><div>corrections.<br><br></div><div>regards,<br></div><div>sumera</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
thanks,<br>
<br>
greg k-h<br>
</blockquote></div></div>