summaryrefslogtreecommitdiff
path: root/tools/lsgpu.c
diff options
context:
space:
mode:
authorAyaz A Siddiqui <ayaz.siddiqui@intel.com>2020-03-20 01:01:12 +0530
committerLucas De Marchi <lucas.demarchi@intel.com>2021-04-07 14:54:06 -0700
commit4aa7cd3ac664af4a7ca87d3fa8ed44208e4b0fa5 (patch)
treea47173f607cc0a4765bbac072d626cb0b46615e0 /tools/lsgpu.c
parent26b0a1ccd0ee0bff29e55d18c3fd8cbf83299049 (diff)
tool/lsgpu: Fix memory leak when no device is found
Memory allocated during device scan were not being freed. added call of igt_devices_free(). Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Ayaz A Siddiqui <ayaz.siddiqui@intel.com> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Acked-by: Matt Roper <matthew.d.roper@intel.com>
Diffstat (limited to 'tools/lsgpu.c')
-rw-r--r--tools/lsgpu.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/lsgpu.c b/tools/lsgpu.c
index 25358bbe7..27e76f261 100644
--- a/tools/lsgpu.c
+++ b/tools/lsgpu.c
@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
{"help", no_argument, NULL, OPT_HELP},
{0, 0, 0, 0}
};
- int c, index = 0;
+ int c, ret = 0, index = 0;
char *env_device = NULL, *opt_device = NULL, *rc_device = NULL;
struct igt_devices_print_format fmt = {
.type = IGT_PRINT_USER,
@@ -257,7 +257,8 @@ int main(int argc, char *argv[])
if (!igt_device_card_match(igt_device, &card)) {
printf("No device found for the filter\n\n");
- return -1;
+ ret = -1;
+ goto out;
}
printf("Device detail:\n");
@@ -272,9 +273,10 @@ int main(int argc, char *argv[])
} else {
igt_devices_print(&fmt);
}
-
+out:
+ igt_devices_free();
free(rc_device);
free(opt_device);
- return 0;
+ return ret;
}