diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2020-06-10 11:56:53 +0300 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2020-07-01 01:59:19 -0400 |
commit | 8df1a28f41b9593301353c4f419c0fd93c40a26f (patch) | |
tree | 916d6d101740090bd915bbaacdd753b31fafc63a /drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c | |
parent | 3466a8f0c2fc9e428dc96b270037dfe657521f43 (diff) | |
download | linux-8df1a28f41b9593301353c4f419c0fd93c40a26f.tar.gz linux-8df1a28f41b9593301353c4f419c0fd93c40a26f.tar.bz2 linux-8df1a28f41b9593301353c4f419c0fd93c40a26f.zip |
drm/amdgpu: Fix a buffer overflow handling the serial number
The comments say that the serial number is a 16-digit HEX string so the
buffer needs to be at least 17 characters to hold the NUL terminator.
The other issue is that "size" returned from sprintf() is the number of
characters before the NUL terminator so the memcpy() wasn't copying the
terminator. The serial number needs to be NUL terminated so that it
doesn't lead to a read overflow in amdgpu_device_get_serial_number().
Also it's just cleaner and faster to sprintf() directly to adev->serial[]
instead of using a temporary buffer.
Fixes: 81a16241114b ("drm/amdgpu: Add unique_id and serial_number for Arcturus v3")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Evan Quan <evan.quan@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c')
0 files changed, 0 insertions, 0 deletions