mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
drm/amdgpu: fix duplicated buffer allocation for concurrent
In case of concurrent calling to the bin file writing, use the mutex to avoid allocating the temporary buffer more than once. Signed-off-by: Shiwu Zhang <shiwu.zhang@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
6229898d46
commit
2064610469
|
|
@ -4651,14 +4651,17 @@ static ssize_t amdgpu_psp_vbflash_write(struct file *filp, struct kobject *kobj,
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
mutex_lock(&adev->psp.mutex);
|
||||
|
||||
/* TODO Just allocate max for now and optimize to realloc later if needed */
|
||||
if (!adev->psp.vbflash_tmp_buf) {
|
||||
adev->psp.vbflash_tmp_buf = kvmalloc(AMD_VBIOS_FILE_MAX_SIZE_B, GFP_KERNEL);
|
||||
if (!adev->psp.vbflash_tmp_buf)
|
||||
if (!adev->psp.vbflash_tmp_buf) {
|
||||
mutex_unlock(&adev->psp.mutex);
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
mutex_lock(&adev->psp.mutex);
|
||||
memcpy(adev->psp.vbflash_tmp_buf + pos, buffer, count);
|
||||
adev->psp.vbflash_image_size += count;
|
||||
mutex_unlock(&adev->psp.mutex);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user