Received: from list by lists.gnu.org with archive (Exim 4.71) id 1eHtIJ-0005Yw-KL for mharc-grub-devel@gnu.org; Thu, 23 Nov 2017 10:20:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHtID-0005VK-91 for grub-devel@gnu.org; Thu, 23 Nov 2017 10:20:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eHtIA-0004vY-IA for grub-devel@gnu.org; Thu, 23 Nov 2017 10:19:57 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:20602) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eHtIA-0004rN-AL for grub-devel@gnu.org; Thu, 23 Nov 2017 10:19:54 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vANFJprp031025 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 23 Nov 2017 15:19:51 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 vANFJpgT027100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 23 Nov 2017 15:19:51 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id vANFJnRb024058 for ; Thu, 23 Nov 2017 15:19:51 GMT Received: from olila.local.net-space.pl (/10.175.194.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 23 Nov 2017 07:19:49 -0800 Date: Thu, 23 Nov 2017 16:19:40 +0100 From: Daniel Kiper To: Eric Snowberg Cc: The development of GNU GRUB Subject: Re: [PATCH v2] ls: prevent double open Message-ID: <20171123151940.GQ12877@olila.local.net-space.pl> References: <1510590448-182206-1-git-send-email-eric.snowberg@oracle.com> <20171121132012.GI12877@olila.local.net-space.pl> <0B217BB5-37E9-4C16-BDA0-4CEDD3D90E53@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <0B217BB5-37E9-4C16-BDA0-4CEDD3D90E53@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0022.oracle.com [156.151.31.74] Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by aserp1040.oracle.com id vANFJprp031025 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 141.146.126.69 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: Thu, 23 Nov 2017 15:20:02 -0000 On Tue, Nov 21, 2017 at 03:24:38PM -0700, Eric Snowberg wrote: > > On Nov 21, 2017, at 6:20 AM, Daniel Kiper w= rote: > > 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 =3D grub_device_open (device_name); > >> dev remains open while: > >> grub_normal_print_device_info (device_name); > >> dev =3D 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 =3D=3D GRUB_ERR_UNKNOWN_FS) > >> grub_errno =3D GRUB_ERR_NONE; > >> > >> + /* Close device to prevent a double open in > >> + grub_normal_print_device_info. */ > >> + grub_device_close (dev); > >> + dev =3D NULL; > > > > Are you OK if I put above between "#ifdef GRUB_MACHINE_IEEE1275" and = "#endif=E2=80=9D? > > I suppose you could add that. Great! > Is this patch causing problems on a different platform? Nope, but I would like to be on safe side. So, I will add it and push. Daniel