util/grub-probe: fix memory leaks.

Found by: Coverity scan.
This commit is contained in:
Andrei Borzenkov 2015-01-27 21:29:55 +03:00
parent edc94e4b0b
commit 11aae26cc3

View file

@ -295,6 +295,7 @@ probe (const char *path, char **device_names, char delim)
} }
printf ("%s", disk); printf ("%s", disk);
putchar (delim); putchar (delim);
free (disk);
} }
return; 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); grub_util_fprint_full_disk_name (stdout, dev->disk->name, dev);
putchar (delim); putchar (delim);
grub_device_close (dev);
continue; continue;
} }
@ -542,7 +544,7 @@ probe (const char *path, char **device_names, char delim)
if (print == PRINT_IEEE1275_HINT) if (print == PRINT_IEEE1275_HINT)
{ {
const char *osdev = grub_util_biosdisk_get_osdev (dev->disk); 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; const char *map;
map = grub_util_biosdisk_get_compatibility_hint (dev->disk); 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); strcpy (p, ofpath);
grub_util_fprint_full_disk_name (stdout, tmp, dev); grub_util_fprint_full_disk_name (stdout, tmp, dev);
free (tmp); free (tmp);
free (ofpath);
putchar (delim); putchar (delim);
} }