Received: from list by lists.gnu.org with archive (Exim 4.71) id 1e4RpV-0005ku-HX for mharc-grub-devel@gnu.org; Tue, 17 Oct 2017 09:22:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4RpO-0005gF-CG for grub-devel@gnu.org; Tue, 17 Oct 2017 09:22:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4RpI-00056d-Fr for grub-devel@gnu.org; Tue, 17 Oct 2017 09:22:38 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:30096) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e4RpI-00054d-6g for grub-devel@gnu.org; Tue, 17 Oct 2017 09:22:32 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v9HDMTdn002875 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Oct 2017 13:22:29 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v9HDMTFC019343 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Oct 2017 13:22:29 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v9HDMSJ4028377; Tue, 17 Oct 2017 13:22:28 GMT Received: from olila.local.net-space.pl (/10.175.205.25) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 17 Oct 2017 06:22:28 -0700 Date: Tue, 17 Oct 2017 15:22:24 +0200 From: Daniel Kiper To: Eric Snowberg Cc: grub-devel@gnu.org, phcoder@gmail.com Subject: Re: [PATCH] ls: prevent double open Message-ID: <20171017132224.GU7593@olila.local.net-space.pl> References: <1508184672-164532-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: <1508184672-164532-1-git-send-email-eric.snowberg@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: aserv0022.oracle.com [141.146.126.234] 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, 17 Oct 2017 13:22:44 -0000 On Mon, Oct 16, 2017 at 01:11:12PM -0700, 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 In general LGTM. One nitpick... > --- > 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; I would put a comment before why it is needed. Thanks, Daniel