From 11aae26cc374d01c9bf4fa33f792bff16b444ef5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 21:29:55 +0300 Subject: [PATCH] util/grub-probe: fix memory leaks. Found by: Coverity scan. --- util/grub-probe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/grub-probe.c b/util/grub-probe.c index ecb7b6bbd..8a0c4f35b 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -295,6 +295,7 @@ probe (const char *path, char **device_names, char delim) } printf ("%s", disk); putchar (delim); + free (disk); } return; } @@ -496,6 +497,7 @@ probe (const char *path, char **device_names, char delim) { grub_util_fprint_full_disk_name (stdout, dev->disk->name, dev); putchar (delim); + grub_device_close (dev); continue; } @@ -542,7 +544,7 @@ probe (const char *path, char **device_names, char delim) if (print == PRINT_IEEE1275_HINT) { const char *osdev = grub_util_biosdisk_get_osdev (dev->disk); - const char *ofpath = grub_util_devname_to_ofpath (osdev); + char *ofpath = grub_util_devname_to_ofpath (osdev); const char *map; map = grub_util_biosdisk_get_compatibility_hint (dev->disk); @@ -560,6 +562,7 @@ probe (const char *path, char **device_names, char delim) strcpy (p, ofpath); grub_util_fprint_full_disk_name (stdout, tmp, dev); free (tmp); + free (ofpath); putchar (delim); }