Skip to contentSkip to conversation

Fix a memory leak bug for umr tool.

PATCH 张二东 2 participants 2 messages Aug 14, 2020 – Aug 21, 2020

lore
Share & tools
lore

张二东

author
#0 lore raw

Hi:
The function umr_pm4_decode_ring_is_halted call umr_read_ring_data

to get ringdata, umr_read_ring_data will alloc memory to store ring

data and return the memory pointer to umr_pm4_decode_ring_is_halted, So

the memory should be free in umr_pm4_decode_ring_is_halted.

Thanks.

From 0d4ddc058c433c1887e4c819bc713f1d842fd7c1 Mon Sep 17 00:00:00 2001
From: Erdong zhang <[email protected]>
Date: Fri, 14 Aug 2020 09:43:11 +0800
Subject: [PATCH] fix a memory leak bug in function
umr_pm4_decode_ring_is_halted

The function umr_pm4_decode_ring_is_halted call umr_read_ring_data
to get ringdata, umr_read_ring_data will alloc memory to store ring data and return the memory pointer to umr_pm4_decode_ring_is_halted, So the memory should be free in umr_pm4_decode_ring_is_halted.

---
 src/lib/umr_read_pm4_stream.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
src/lib/umr_read_pm4_stream.c +5 -1
index 5d1760e..b7dcb91 100644
@@ -337,10 +337,14 @@ int umr_pm4_decode_ring_is_halted(struct umr_asic *asic, char *ringname)
 		ringsize /= 4;
 		ringdata[0] %= ringsize;
 		ringdata[1] %= ringsize;
-		if (ringdata[0] == ringdata[1])
+		if (ringdata[0] == ringdata[1]){
+			free(ringdata);
 			return 0;
+		}
 		usleep(5);
 	}
+	
+	free(ringdata);
 	return 1;
 }
 
Signature · 1 line
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#1 lore raw

Sorry I missed this. I've applied it (with whitespace fixes) and pushed it out to main yesterday.

Cheers,
Tom

Quoted 8 lines · 张二东

Hi:
The function umr_pm4_decode_ring_is_halted call umr_read_ring_data

to get ringdata, umr_read_ring_data will alloc memory to store ring

data and return the memory pointer to umr_pm4_decode_ring_is_halted, So the memory should be free in umr_pm4_decode_ring_is_halted.

Quoted 9 lines

Thanks.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx