Received: from list by lists.gnu.org with archive (Exim 4.71) id 1eH8Td-00019y-N2 for mharc-grub-devel@gnu.org; Tue, 21 Nov 2017 08:20:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eH8TS-00017a-JG for grub-devel@gnu.org; Tue, 21 Nov 2017 08:20:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eH8TL-0004Fk-75 for grub-devel@gnu.org; Tue, 21 Nov 2017 08:20:26 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:33825) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eH8TK-0004F5-UW for grub-devel@gnu.org; Tue, 21 Nov 2017 08:20:19 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vALDKGh6030988 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 21 Nov 2017 13:20:16 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vALDKGxa017878 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 21 Nov 2017 13:20:16 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id vALDKFk2031546 for ; Tue, 21 Nov 2017 13:20:15 GMT Received: from olila.local.net-space.pl (/10.175.179.27) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 21 Nov 2017 05:20:15 -0800 Date: Tue, 21 Nov 2017 14:20:12 +0100 From: Daniel Kiper To: Eric Snowberg Cc: grub-devel@gnu.org Subject: Re: [PATCH v2] ls: prevent double open Message-ID: <20171121132012.GI12877@olila.local.net-space.pl> References: <1510590448-182206-1-git-send-email-eric.snowberg@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1510590448-182206-1-git-send-email-eric.snowberg@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0022.oracle.com [156.151.31.74] 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: Tue, 21 Nov 2017 13:20:36 -0000 On Mon, Nov 13, 2017 at 08:27:28AM -0800, Eric Snowberg wrote: > 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; Are you OK if I put above between "#ifdef GRUB_MACHINE_IEEE1275" and "#endif"? Daniel