Skip to contentSkip to conversation

drm/etnaviv: fix error code in event_alloc()

PATCH In review Dan Carpenter 2 participants 2 messages Jul 19, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/etnaviv: fix error code in event_alloc()

There are two "ret" variables declared in this function so setting "ret = -EBUSY;" sets the wrong one. The function ends up returning an uninitialized variable.

Fixes f098f9b8042a ("drm/etnaviv: move runtime PM handling to events")
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +4 -4
index f54f12090685..0382cd91eebf 100644
@@ -1158,18 +1158,18 @@ static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
 	int ret;
 
 	for (i = 0; i < nr_events; i++) {
-		unsigned long ret;
+		unsigned long remaining;
 
-		ret = wait_for_completion_timeout(&gpu->event_free, timeout);
+		remaining = wait_for_completion_timeout(&gpu->event_free, timeout);
 
-		if (!ret) {
+		if (!remaining) {
 			dev_err(gpu->dev, "wait_for_completion_timeout failed");
 			ret = -EBUSY;
 			goto out;
 		}
 
 		acquired++;
-		timeout = ret;
+		timeout = remaining;
 	}
 
 	spin_lock(&gpu->event_spinlock);
Signature · 1 line
2.39.2
maintainer
#1 lore raw

Hi Dan,

Am Mittwoch, dem 19.07.2023 um 13:17 +0300 schrieb Dan Carpenter:

Quoted 4 lines

There are two "ret" variables declared in this function so setting "ret = -EBUSY;" sets the wrong one. The function ends up returning an uninitialized variable.

Thanks for the fix. Applied to the etnaviv/next branch where the offending commit sits right now.

Regards,
Lucas

Quoted 33 lines
Fixes f098f9b8042a ("drm/etnaviv: move runtime PM handling to events")
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +4 -4
index f54f12090685..0382cd91eebf 100644
@@ -1158,18 +1158,18 @@ static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
 	int ret;
 
 	for (i = 0; i < nr_events; i++) {
-		unsigned long ret;
+		unsigned long remaining;
 
-		ret = wait_for_completion_timeout(&gpu->event_free, timeout);
+		remaining = wait_for_completion_timeout(&gpu->event_free, timeout);
 
-		if (!ret) {
+		if (!remaining) {
 			dev_err(gpu->dev, "wait_for_completion_timeout failed");
 			ret = -EBUSY;
 			goto out;
 		}
 
 		acquired++;
-		timeout = ret;
+		timeout = remaining;
 	}
 
 	spin_lock(&gpu->event_spinlock);