svn commit: r313442 - head/sys/boot/efi/libefi
Toomas Soome
tsoome at FreeBSD.org
Wed Feb 8 15:52:10 UTC 2017
Author: tsoome
Date: Wed Feb 8 15:52:09 2017
New Revision: 313442
URL: https://svnweb.freebsd.org/changeset/base/313442
Log:
loader: possible NULL pointer dereference in efipart.c
Fix bugs found by Coverity in efipart.c.
The Issue is that efi_devpath_last_node() can return NULL pointer, and
therefore we should check for it. In real life we really do not
expect to see it to happen, so we will just error out from the test.
CID: 1371004
Reported by: Coverity
Reviewed by: allanjude
Approved by: allanjude (mentor)
Differential Revision: https://reviews.freebsd.org/D9490
Modified:
head/sys/boot/efi/libefi/efipart.c
Modified: head/sys/boot/efi/libefi/efipart.c
==============================================================================
--- head/sys/boot/efi/libefi/efipart.c Wed Feb 8 13:37:57 2017 (r313441)
+++ head/sys/boot/efi/libefi/efipart.c Wed Feb 8 15:52:09 2017 (r313442)
@@ -364,6 +364,9 @@ efipart_hdinfo_add(EFI_HANDLE disk_handl
if (disk_devpath == NULL || part_devpath == NULL) {
return (ENOENT);
}
+ node = (HARDDRIVE_DEVICE_PATH *)efi_devpath_last_node(part_devpath);
+ if (node == NULL)
+ return (ENOENT); /* This should not happen. */
pd = malloc(sizeof(pdinfo_t));
if (pd == NULL) {
@@ -372,7 +375,6 @@ efipart_hdinfo_add(EFI_HANDLE disk_handl
}
memset(pd, 0, sizeof(pdinfo_t));
STAILQ_INIT(&pd->pd_part);
- node = (HARDDRIVE_DEVICE_PATH *)efi_devpath_last_node(part_devpath);
STAILQ_FOREACH(hd, &hdinfo, pd_link) {
if (efi_devpath_match(hd->pd_devpath, disk_devpath) != 0) {
More information about the svn-src-all
mailing list