Received: from list by lists.gnu.org with archive (Exim 4.71) id 1e4Bk3-0002kn-3w for mharc-grub-devel@gnu.org; Mon, 16 Oct 2017 16:12:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Bk0-0002kC-Nv for grub-devel@gnu.org; Mon, 16 Oct 2017 16:12:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4Bjw-0005kV-Bk for grub-devel@gnu.org; Mon, 16 Oct 2017 16:12:00 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:46559) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e4Bjw-0005kD-4J for grub-devel@gnu.org; Mon, 16 Oct 2017 16:11:56 -0400 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 v9GKBqes016905 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Oct 2017 20:11:53 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v9GKBqAL000750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Oct 2017 20:11:52 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v9GKBpnZ007867; Mon, 16 Oct 2017 20:11:51 GMT Received: from ca-qasparc20.us.oracle.com (/10.147.24.73) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Oct 2017 13:11:51 -0700 From: Eric Snowberg To: grub-devel@gnu.org Cc: phcoder@gmail.com, daniel.kiper@oracle.com, Eric Snowberg Subject: [PATCH] ls: prevent double open Date: Mon, 16 Oct 2017 13:11:12 -0700 Message-Id: <1508184672-164532-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, 16 Oct 2017 20:12:02 -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 --- grub-core/commands/ls.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c index 0eaf836..a7318ab 100644 --- a/grub-core/commands/ls.c +++ b/grub-core/commands/ls.c @@ -201,6 +201,8 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human) if (grub_errno == GRUB_ERR_UNKNOWN_FS) grub_errno = GRUB_ERR_NONE; + grub_device_close (dev); + dev = NULL; grub_normal_print_device_info (device_name); } else if (fs) -- 1.7.1