ieee1275: Fix crash in of_path_of_nvme when of_path is empty
PATCH v3 1/1 ieee1275: Fix crash in of_path_of_nvme when of_path is empty
Hi!
As suggested by James Clarke earlier on this mailing list today, I have modified of_path_of_nvme such that it behaves the same way as of_path_of_scsi and just returns NULL when the call to find_obppath returns NULL.
This makes much more sense than what my previous patch did as we don't want of_path_of_nvme to return anything but NULL when not run on a system not based on Open Firmware.
Thanks,
Adrian
PATCH 1/1 ieee1275: Fix crash in of_path_of_nvme when of_path is empty
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.
--- grub-core/osdep/linux/ofpath.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
grub-core/osdep/linux/ofpath.c +4 -1
@@ -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; }
Signature · 1 line
2.16.2
Quoted 39 lines · John Paul Adrian Glaubitz
The
of_path_of_nvmefunction (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_obppathwill return NULL and thus trying to append the disk name toof_pathwill result in a crash.The proper behavior of
of_path_of_nvmeis, however, to just return NULL in such cases, like other users offind_obppath, such asof_path_of_scsi.Signed-off-by John Paul Adrian Glaubitz <[email protected]>---
grub-core/osdep/linux/ofpath.c| 5 ++++-1 file changed, 4 insertions(+), 1 deletion(-)grub-core/osdep/linux/ofpath.c +4
-1@@ -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; }Signature · 1 line
2.16.2
Daniel Kiper
AppliedQuoted 36 lines · Eric Snowberg
Quoted 36 lines · John Paul Adrian Glaubitz
The
of_path_of_nvmefunction (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_obppathwill return NULL and thus trying to append the disk name toof_pathwill result in a crash.The proper behavior of
of_path_of_nvmeis, however, to just return NULL in such cases, like other users offind_obppath, such asof_path_of_scsi.Signed-off-by John Paul Adrian Glaubitz <[email protected]>---
grub-core/osdep/linux/ofpath.c| 5 ++++-1 file changed, 4 insertions(+), 1 deletion(-)grub-core/osdep/linux/ofpath.c +4
-1@@ -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; }
Quoted 4 lines
Quoted 2 lines
--
2.16.2Reviewed-by Eric Snowberg <[email protected]>
Applied. Please CC me next time.
Daniel