Blame SOURCES/0513-kern-file-Do-not-leak-device_name-on-error-in-grub_f.patch

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