* [PATCH] drm/amdgpu: Add null pointer check before task_info get and put
@ 2025-01-01 1:58 Lu Yao
2025-01-02 14:12 ` Sharma, Shashank
0 siblings, 1 reply; 2+ messages in thread
From: Lu Yao @ 2025-01-01 1:58 UTC (permalink / raw)
To: alexander.deucher, christian.koenig, Xinhui.Pan
Cc: felix.kuehling, shashank.sharma, tvrtko.ursulin, zhenguo.yin,
amd-gfx, dri-devel, linux-kernel, Lu Yao
This patch add null pointer check for amdgpu_vm_put_task_info and
amdgpu_vm_get_task_info_vm, because there is only a warning if create
task_info failed in amdgpu_vm_init.
Fixes: b8f67b9ddf4f ("drm/amdgpu: change vm->task_info handling")
Signed-off-by: Lu Yao <yaolu@kylinos.cn>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index c9c48b782ec1..65edd74bd944 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2336,7 +2336,8 @@ amdgpu_vm_get_vm_from_pasid(struct amdgpu_device *adev, u32 pasid)
*/
void amdgpu_vm_put_task_info(struct amdgpu_task_info *task_info)
{
- kref_put(&task_info->refcount, amdgpu_vm_destroy_task_info);
+ if (task_info)
+ kref_put(&task_info->refcount, amdgpu_vm_destroy_task_info);
}
/**
@@ -2352,7 +2353,7 @@ amdgpu_vm_get_task_info_vm(struct amdgpu_vm *vm)
{
struct amdgpu_task_info *ti = NULL;
- if (vm) {
+ if (vm && vm->task_info) {
ti = vm->task_info;
kref_get(&vm->task_info->refcount);
}
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amdgpu: Add null pointer check before task_info get and put
2025-01-01 1:58 [PATCH] drm/amdgpu: Add null pointer check before task_info get and put Lu Yao
@ 2025-01-02 14:12 ` Sharma, Shashank
0 siblings, 0 replies; 2+ messages in thread
From: Sharma, Shashank @ 2025-01-02 14:12 UTC (permalink / raw)
To: Lu Yao, alexander.deucher, christian.koenig, Xinhui.Pan
Cc: felix.kuehling, tvrtko.ursulin, zhenguo.yin, amd-gfx, dri-devel,
linux-kernel
Lgtm, Reviewed-by: Shashank Sharma <shashank.sharma@amd.com>
Regards
Shashank
On 01/01/2025 02:58, Lu Yao wrote:
> This patch add null pointer check for amdgpu_vm_put_task_info and
> amdgpu_vm_get_task_info_vm, because there is only a warning if create
> task_info failed in amdgpu_vm_init.
>
> Fixes: b8f67b9ddf4f ("drm/amdgpu: change vm->task_info handling")
> Signed-off-by: Lu Yao <yaolu@kylinos.cn>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index c9c48b782ec1..65edd74bd944 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -2336,7 +2336,8 @@ amdgpu_vm_get_vm_from_pasid(struct amdgpu_device *adev, u32 pasid)
> */
> void amdgpu_vm_put_task_info(struct amdgpu_task_info *task_info)
> {
> - kref_put(&task_info->refcount, amdgpu_vm_destroy_task_info);
> + if (task_info)
> + kref_put(&task_info->refcount, amdgpu_vm_destroy_task_info);
> }
>
> /**
> @@ -2352,7 +2353,7 @@ amdgpu_vm_get_task_info_vm(struct amdgpu_vm *vm)
> {
> struct amdgpu_task_info *ti = NULL;
>
> - if (vm) {
> + if (vm && vm->task_info) {
> ti = vm->task_info;
> kref_get(&vm->task_info->refcount);
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-02 14:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-01 1:58 [PATCH] drm/amdgpu: Add null pointer check before task_info get and put Lu Yao
2025-01-02 14:12 ` Sharma, Shashank
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®