Skip to content

Commit c5d5a32

Browse files
Navidemlynxeye-dev
authored andcommitted
drm/etnaviv: fix ref count leak via pm_runtime_get_sync
in etnaviv_gpu_submit, etnaviv_gpu_recover_hang, etnaviv_gpu_debugfs, and etnaviv_gpu_init the call to pm_runtime_get_sync increments the counter even in case of failure, leading to incorrect ref count. In case of failure, decrement the ref count before returning. Signed-off-by: Navid Emamdoost <[email protected]> Signed-off-by: Lucas Stach <[email protected]>
1 parent 6a5ef3b commit c5d5a32

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/gpu/drm/etnaviv/etnaviv_gpu.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
722722
ret = pm_runtime_get_sync(gpu->dev);
723723
if (ret < 0) {
724724
dev_err(gpu->dev, "Failed to enable GPU power domain\n");
725-
return ret;
725+
goto pm_put;
726726
}
727727

728728
etnaviv_hw_identify(gpu);
@@ -819,6 +819,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
819819

820820
fail:
821821
pm_runtime_mark_last_busy(gpu->dev);
822+
pm_put:
822823
pm_runtime_put_autosuspend(gpu->dev);
823824

824825
return ret;
@@ -859,7 +860,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
859860

860861
ret = pm_runtime_get_sync(gpu->dev);
861862
if (ret < 0)
862-
return ret;
863+
goto pm_put;
863864

864865
dma_lo = gpu_read(gpu, VIVS_FE_DMA_LOW);
865866
dma_hi = gpu_read(gpu, VIVS_FE_DMA_HIGH);
@@ -1003,6 +1004,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
10031004
ret = 0;
10041005

10051006
pm_runtime_mark_last_busy(gpu->dev);
1007+
pm_put:
10061008
pm_runtime_put_autosuspend(gpu->dev);
10071009

10081010
return ret;
@@ -1016,7 +1018,7 @@ void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
10161018
dev_err(gpu->dev, "recover hung GPU!\n");
10171019

10181020
if (pm_runtime_get_sync(gpu->dev) < 0)
1019-
return;
1021+
goto pm_put;
10201022

10211023
mutex_lock(&gpu->lock);
10221024

@@ -1035,6 +1037,7 @@ void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
10351037

10361038
mutex_unlock(&gpu->lock);
10371039
pm_runtime_mark_last_busy(gpu->dev);
1040+
pm_put:
10381041
pm_runtime_put_autosuspend(gpu->dev);
10391042
}
10401043

@@ -1308,8 +1311,10 @@ struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit)
13081311

13091312
if (!submit->runtime_resumed) {
13101313
ret = pm_runtime_get_sync(gpu->dev);
1311-
if (ret < 0)
1314+
if (ret < 0) {
1315+
pm_runtime_put_noidle(gpu->dev);
13121316
return NULL;
1317+
}
13131318
submit->runtime_resumed = true;
13141319
}
13151320

@@ -1326,6 +1331,7 @@ struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit)
13261331
ret = event_alloc(gpu, nr_events, event);
13271332
if (ret) {
13281333
DRM_ERROR("no free events\n");
1334+
pm_runtime_put_noidle(gpu->dev);
13291335
return NULL;
13301336
}
13311337

0 commit comments

Comments
 (0)