Received: from list by lists.gnu.org with archive (Exim 4.71) id 1eEHad-00051L-95 for mharc-grub-devel@gnu.org; Mon, 13 Nov 2017 11:28:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEHaa-0004yz-8H for grub-devel@gnu.org; Mon, 13 Nov 2017 11:28:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eEHaW-0006OJ-7g for grub-devel@gnu.org; Mon, 13 Nov 2017 11:28:00 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:25824) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eEHaV-0006E6-Vv for grub-devel@gnu.org; Mon, 13 Nov 2017 11:27:56 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vADGRhs6023348 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 13 Nov 2017 16:27:43 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vADGRgxm024235 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 13 Nov 2017 16:27:43 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id vADGRgfX004484 for ; Mon, 13 Nov 2017 16:27:42 GMT Received: from ca-qasparc20.us.oracle.com (/10.147.24.73) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 13 Nov 2017 08:27:41 -0800 From: Eric Snowberg To: grub-devel@gnu.org Cc: daniel.kiper@oracle.com, Eric Snowberg Subject: [PATCH v2] ls: prevent double open Date: Mon, 13 Nov 2017 08:27:28 -0800 Message-Id: <1510590448-182206-1-git-send-email-eric.snowberg@oracle.com> X-Mailer: git-send-email 1.7.1 X-Source-IP: aserv0021.oracle.com [141.146.126.233] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 156.151.31.81 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Nov 2017 16:28:01 -0000 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 --- changes from v1: - Added comment --- grub-core/commands/ls.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c index 0eaf836..fcbb3da 100644 --- a/grub-core/commands/ls.c +++ b/grub-core/commands/ls.c @@ -201,6 +201,10 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human) if (grub_errno == GRUB_ERR_UNKNOWN_FS) grub_errno = GRUB_ERR_NONE; + /* Close device to prevent a double open in + grub_normal_print_device_info. */ + grub_device_close (dev); + dev = NULL; grub_normal_print_device_info (device_name); } else if (fs) -- 1.7.1