mirror of
https://git.proxmox.com/git/mirror_ubuntu-kernels.git
synced 2025-12-17 19:12:23 +00:00
drm/amdgpu: Fix a bug for input with double sscanf
Remove double-sscanf to scan for %llu and 0x%llx, as that is not going to work! The %llu will consume the "0" in "0x" of your input, and the hex value you think you're entering will always be 0. That is, a valid hex value can never be consumed. On the other hand, just entering a hex number without leading 0x will either be scanned as a string and not match, for instance FAB123, or the leading decimal portion is scanned as the %llu, for instance 123FAB will be scanned as 123, which is not correct. Thus remove the first %llu scan and leave only the %llx scan, removing the leading 0x since %llx can scan either. Addresses are usually always hex values, so this suffices. Cc: Alexander Deucher <Alexander.Deucher@amd.com> Cc: Xinhui Pan <xinhui.pan@amd.com> Cc: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Luben Tuikov <luben.tuikov@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
b45fdeab45
commit
6cb7a1d40a
@ -230,9 +230,8 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,
|
|||||||
if (op != -1) {
|
if (op != -1) {
|
||||||
|
|
||||||
if (op == 3) {
|
if (op == 3) {
|
||||||
if (sscanf(str, "%*s %llu", &address) != 1)
|
if (sscanf(str, "%*s %llx", &address) != 1)
|
||||||
if (sscanf(str, "%*s 0x%llx", &address) != 1)
|
return -EINVAL;
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
data->op = op;
|
data->op = op;
|
||||||
data->inject.address = address;
|
data->inject.address = address;
|
||||||
@ -255,11 +254,9 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,
|
|||||||
data->op = op;
|
data->op = op;
|
||||||
|
|
||||||
if (op == 2) {
|
if (op == 2) {
|
||||||
if (sscanf(str, "%*s %*s %*s %u %llu %llu",
|
if (sscanf(str, "%*s %*s %*s %x %llx %llx",
|
||||||
&sub_block, &address, &value) != 3)
|
&sub_block, &address, &value) != 3)
|
||||||
if (sscanf(str, "%*s %*s %*s 0x%x 0x%llx 0x%llx",
|
return -EINVAL;
|
||||||
&sub_block, &address, &value) != 3)
|
|
||||||
return -EINVAL;
|
|
||||||
data->head.sub_block_index = sub_block;
|
data->head.sub_block_index = sub_block;
|
||||||
data->inject.address = address;
|
data->inject.address = address;
|
||||||
data->inject.value = value;
|
data->inject.value = value;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user