Received: from list by lists.gnu.org with archive (Exim 4.71) id 1erWn8-0002Ng-SB for mharc-grub-devel@gnu.org; Thu, 01 Mar 2018 17:35:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erWn6-0002Kr-6H for grub-devel@gnu.org; Thu, 01 Mar 2018 17:35:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erWn3-00084s-21 for grub-devel@gnu.org; Thu, 01 Mar 2018 17:35:08 -0500 Received: from outpost18.zedat.fu-berlin.de ([130.133.4.111]:41302) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1erWn2-000838-Qx for grub-devel@gnu.org; Thu, 01 Mar 2018 17:35:04 -0500 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by outpost.zedat.fu-berlin.de (Exim 4.85) with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (envelope-from ) id <1erWn1-003VYQ-FZ>; Thu, 01 Mar 2018 23:35:03 +0100 Received: from z6.physik.fu-berlin.de ([160.45.32.137] helo=z6) by relay1.zedat.fu-berlin.de (Exim 4.85) with esmtps (TLSv1.2:AES256-GCM-SHA384:256) (envelope-from ) id <1erWn1-003YGP-Bl>; Thu, 01 Mar 2018 23:35:03 +0100 Received: from glaubitz by z6 with local (Exim 4.90_1) (envelope-from ) id 1erWmw-0007Z4-CQ; Thu, 01 Mar 2018 23:34:58 +0100 From: John Paul Adrian Glaubitz To: grub-devel@gnu.org Cc: eric.snowberg@oracle.com, 891773@bugs.debian.org, John Paul Adrian Glaubitz Subject: [PATCH] ieee1275: Fix crash in of_path_of_nvme when of_path is empty Date: Thu, 1 Mar 2018 23:34:53 +0100 Message-Id: <20180301223453.28642-2-glaubitz@physik.fu-berlin.de> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180301223453.28642-1-glaubitz@physik.fu-berlin.de> References: <20180301223453.28642-1-glaubitz@physik.fu-berlin.de> X-Originating-IP: 160.45.32.137 X-ZEDAT-Hint: RV X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 130.133.4.111 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, 01 Mar 2018 22:35:09 -0000 The of_path_of_nvme function (commit 2391d57, ieee1275: add nvme support within ofpath) introduced a functional regression: On systems which are not based on Open Firmware but have at least one NVME device, find_obppath will return NULL and thus trying to append the disk name to of_path will result in a crash. The proper behavior of of_path_of_nvme is, however, to just return NULL in such cases, like other users of find_obppath, such as of_path_of_scsi. Signed-off-by: John Paul Adrian Glaubitz --- grub-core/osdep/linux/ofpath.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 1c30e7233..61806212e 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -389,8 +389,11 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)), } of_path = find_obppath (sysfs_path); + + if (of_path) + strcat (of_path, disk); + free (sysfs_path); - strcat (of_path, disk); return of_path; } -- 2.16.2