|
|
d18179 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
d18179 |
From: Daniel Axtens <dja@axtens.net>
|
|
|
d18179 |
Date: Fri, 25 Jun 2021 02:19:05 +1000
|
|
|
d18179 |
Subject: [PATCH] kern/file: Do not leak device_name on error in
|
|
|
d18179 |
grub_file_open()
|
|
|
d18179 |
|
|
|
d18179 |
If we have an error in grub_file_open() before we free device_name, we
|
|
|
d18179 |
will leak it.
|
|
|
d18179 |
|
|
|
d18179 |
Free device_name in the error path and null out the pointer in the good
|
|
|
d18179 |
path once we free it there.
|
|
|
d18179 |
|
|
|
d18179 |
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
|
d18179 |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
d18179 |
(cherry picked from commit 1499a5068839fa37cb77ecef4b5bdacbd1ed12ea)
|
|
|
d18179 |
(cherry picked from commit 2ec50b289d8b24922433439533113087f111f110)
|
|
|
d18179 |
(cherry picked from commit 17c36ae88d7d6040cabc01cd4a21e71ff4731668)
|
|
|
d18179 |
(cherry picked from commit 9c2f4b2da5ce570d5614a0849bdae9a95ed1f311)
|
|
|
d18179 |
---
|
|
|
d18179 |
grub-core/kern/file.c | 2 ++
|
|
|
d18179 |
1 file changed, 2 insertions(+)
|
|
|
d18179 |
|
|
|
d18179 |
diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c
|
|
|
d18179 |
index 24da12bb99..ec8c0265bc 100644
|
|
|
d18179 |
--- a/grub-core/kern/file.c
|
|
|
d18179 |
+++ b/grub-core/kern/file.c
|
|
|
d18179 |
@@ -80,6 +80,7 @@ grub_file_open (const char *name)
|
|
|
d18179 |
|
|
|
d18179 |
device = grub_device_open (device_name);
|
|
|
d18179 |
grub_free (device_name);
|
|
|
d18179 |
+ device_name = NULL;
|
|
|
d18179 |
if (! device)
|
|
|
d18179 |
goto fail;
|
|
|
d18179 |
|
|
|
d18179 |
@@ -121,6 +122,7 @@ grub_file_open (const char *name)
|
|
|
d18179 |
return file;
|
|
|
d18179 |
|
|
|
d18179 |
fail:
|
|
|
d18179 |
+ grub_free (device_name);
|
|
|
d18179 |
if (device)
|
|
|
d18179 |
grub_device_close (device);
|
|
|
d18179 |
|