grub2/0090-ls-prevent-double-open.patch
Peter Jones 6b2dd0f731 Another arm building fix.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-07-12 10:56:34 -04:00

43 lines
1.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Eric Snowberg <eric.snowberg@oracle.com>
Date: Mon, 13 Nov 2017 08:27:28 -0800
Subject: [PATCH] ls: prevent double open
Prevent a double open. This can cause problems with some ieee1275
devices, causing the system to hang. The double open can occur
as follows:
grub_ls_list_files (char *dirname, int longlist, int all, int human)
dev = grub_device_open (device_name);
dev remains open while:
grub_normal_print_device_info (device_name);
dev = grub_device_open (name);
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
grub-core/commands/ls.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
index 0eaf8365279..c25161cc4f2 100644
--- a/grub-core/commands/ls.c
+++ b/grub-core/commands/ls.c
@@ -201,6 +201,15 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
if (grub_errno == GRUB_ERR_UNKNOWN_FS)
grub_errno = GRUB_ERR_NONE;
+#ifdef GRUB_MACHINE_IEEE1275
+ /*
+ * Close device to prevent a double open in grub_normal_print_device_info().
+ * Otherwise it may lead to hangs on some IEEE 1275 platforms.
+ */
+ grub_device_close (dev);
+ dev = NULL;
+#endif
+
grub_normal_print_device_info (device_name);
}
else if (fs)