Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: Fix locking bugs in error paths

Do not unlock psp->ras_context.mutex if it has not been locked. This has
been detected by the Clang thread-safety analyzer.

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: YiPeng Chai <YiPeng.Chai@amd.com>
Cc: Hawking Zhang <Hawking.Zhang@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Fixes: b3fb79cda568 ("drm/amdgpu: add mutex to protect ras shared memory")
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 6fa01b4335978051d2cd80841728fd63cc597970)

authored by

Bart Van Assche and committed by
Alex Deucher
480ad5f6 5e0bcc7b

+7 -5
+7 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
··· 332 332 if (!context || !context->initialized) { 333 333 dev_err(adev->dev, "TA is not initialized\n"); 334 334 ret = -EINVAL; 335 - goto err_free_shared_buf; 335 + goto free_shared_buf; 336 336 } 337 337 338 338 if (!psp->ta_funcs || !psp->ta_funcs->fn_ta_invoke) { 339 339 dev_err(adev->dev, "Unsupported function to invoke TA\n"); 340 340 ret = -EOPNOTSUPP; 341 - goto err_free_shared_buf; 341 + goto free_shared_buf; 342 342 } 343 343 344 344 context->session_id = ta_id; ··· 346 346 mutex_lock(&psp->ras_context.mutex); 347 347 ret = prep_ta_mem_context(&context->mem_context, shared_buf, shared_buf_len); 348 348 if (ret) 349 - goto err_free_shared_buf; 349 + goto unlock; 350 350 351 351 ret = psp_fn_ta_invoke(psp, cmd_id); 352 352 if (ret || context->resp_status) { ··· 354 354 ret, context->resp_status); 355 355 if (!ret) { 356 356 ret = -EINVAL; 357 - goto err_free_shared_buf; 357 + goto unlock; 358 358 } 359 359 } 360 360 361 361 if (copy_to_user((char *)&buf[copy_pos], context->mem_context.shared_buf, shared_buf_len)) 362 362 ret = -EFAULT; 363 363 364 - err_free_shared_buf: 364 + unlock: 365 365 mutex_unlock(&psp->ras_context.mutex); 366 + 367 + free_shared_buf: 366 368 kfree(shared_buf); 367 369 368 370 return ret;