From 4633d13854ffb64db476711afd97e00f60c4345a Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Tue, 19 Mar 2019 14:11:09 +0000 Subject: [PATCH] gallium/hud: fix memory leaks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Eric Engestrom Reviewed-by: Lionel Landwerlin Reviewed-by: Marek Olšák --- src/gallium/auxiliary/hud/hud_cpufreq.c | 1 + src/gallium/auxiliary/hud/hud_diskstat.c | 4 +++- src/gallium/auxiliary/hud/hud_nic.c | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_cpufreq.c b/src/gallium/auxiliary/hud/hud_cpufreq.c index d3cf2019c38..9c7b90f7351 100644 --- a/src/gallium/auxiliary/hud/hud_cpufreq.c +++ b/src/gallium/auxiliary/hud/hud_cpufreq.c @@ -151,6 +151,7 @@ hud_cpufreq_graph_install(struct hud_pane *pane, int cpu_index, snprintf(gr->name, sizeof(gr->name), "%s-Max", cfi->name); break; default: + free(gr); return; } diff --git a/src/gallium/auxiliary/hud/hud_diskstat.c b/src/gallium/auxiliary/hud/hud_diskstat.c index 7eaaf35a7c7..6860567a26e 100644 --- a/src/gallium/auxiliary/hud/hud_diskstat.c +++ b/src/gallium/auxiliary/hud/hud_diskstat.c @@ -196,8 +196,10 @@ hud_diskstat_graph_install(struct hud_pane *pane, const char *dev_name, else if (dsi->mode == DISKSTAT_WR) { snprintf(gr->name, sizeof(gr->name), "%s-Write-MB/s", dsi->name); } - else + else { + free(gr); return; + } gr->query_data = dsi; gr->query_new_value = query_dsi_load; diff --git a/src/gallium/auxiliary/hud/hud_nic.c b/src/gallium/auxiliary/hud/hud_nic.c index b6c0d9edd55..5fab3319db2 100644 --- a/src/gallium/auxiliary/hud/hud_nic.c +++ b/src/gallium/auxiliary/hud/hud_nic.c @@ -272,8 +272,10 @@ hud_nic_graph_install(struct hud_pane *pane, const char *nic_name, } else if (nic->mode == NIC_RSSI_DBM) snprintf(gr->name, sizeof(gr->name), "%s-rssi", nic->name); - else + else { + free(gr); return; + } gr->query_data = nic; gr->query_new_value = query_nic_load; -- 2.30.2