aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Axtens <dja@axtens.net>2021-06-25 02:19:05 +1000
committerDaniel Kiper <daniel.kiper@oracle.com>2022-06-07 16:39:32 +0200
commitf1ce0e15e70ea1aafcfa26ad93e7585f65783c6f (patch)
tree97ffc8c705efdc65ba7a43338795a7203377f08b
parent6fe755c5c07bb386fda58306bfd19e4a1c974c53 (diff)
downloadgrub-f1ce0e15e70ea1aafcfa26ad93e7585f65783c6f.tar.gz
kern/file: Do not leak device_name on error in grub_file_open()
If we have an error in grub_file_open() before we free device_name, we will leak it. Free device_name in the error path and null out the pointer in the good path once we free it there. Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
-rw-r--r--grub-core/kern/file.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c
index df24c1fd4..8d48fd50d 100644
--- a/grub-core/kern/file.c
+++ b/grub-core/kern/file.c
@@ -79,6 +79,7 @@ grub_file_open (const char *name, enum grub_file_type type)
device = grub_device_open (device_name);
grub_free (device_name);
+ device_name = NULL;
if (! device)
goto fail;
@@ -131,6 +132,7 @@ grub_file_open (const char *name, enum grub_file_type type)
return file;
fail:
+ grub_free (device_name);
if (device)
grub_device_close (device);