drm/amdgpu: fix a potential information leaking bug
[ Upstream commit 929e571c04 ]
Coccinelle reports a path that the array "data" is never initialized.
The path skips the checks in the conditional branches when either
of callback functions, read_wave_vgprs and read_wave_sgprs, is not
registered. Later, the uninitialized "data" array is read
in the while-loop below and passed to put_user().
Fix the path by allocating the array with kcalloc().
The patch is simplier than adding a fall-back branch that explicitly
calls memset(data, 0, ...). Also it does not need the multiplication
1024*sizeof(*data) as the size parameter for memset() though there is
no risk of integer overflow.
Signed-off-by: Wang Xiayang <xywang.sjtu@sjtu.edu.cn>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
02d4fe0193
commit
68340db992
1 changed files with 1 additions and 1 deletions
|
|
@ -707,7 +707,7 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,
|
|||
thread = (*pos & GENMASK_ULL(59, 52)) >> 52;
|
||||
bank = (*pos & GENMASK_ULL(61, 60)) >> 60;
|
||||
|
||||
data = kmalloc_array(1024, sizeof(*data), GFP_KERNEL);
|
||||
data = kcalloc(1024, sizeof(*data), GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue