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