On Thu, Mar 01, 2018 at 05:00:28PM +0100, John Paul Adrian Glaubitz wrote: > 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 an empty path > and appending the disk name to of_path will therefore result > in a crash. Thus, when of_path is empty, just return the > disk name in of_path_of_nvme. > > Signed-off-by: John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de> > --- > grub-core/osdep/linux/ofpath.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c > index 1c30e7233..da0000f0f 100644 > --- a/grub-core/osdep/linux/ofpath.c > +++ b/grub-core/osdep/linux/ofpath.c > @@ -389,8 +389,13 @@ of_path_of_nvme(const char *sys_devname > __attribute__((unused)), > } > > of_path = find_obppath (sysfs_path); > + > + if(of_path) > + strcat (of_path, disk); > + else > + of_path = strdup(disk); > +
Whitespace issues aside, should it not be returning NULL if of_path is NULL, like the other users of find_obppath, such as of_path_of_scsi? This should restore the behaviour from before of_path_of_nvme was added, as grub_util_devname_to_ofpath would have previously returned NULL due to the unknown type? James > free (sysfs_path); > - strcat (of_path, disk); > return of_path; > } > > -- > 2.16.2