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
This commit is contained in:
parent
635f2911b0
commit
c7bf8909b1
@ -364,6 +364,9 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE part_handle)
|
||||
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_handle, EFI_HANDLE part_handle)
|
||||
}
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user