Author: imp
Date: Mon May 6 18:39:22 2019
New Revision: 347194
URL: https://svnweb.freebsd.org/changeset/base/347194
Log:
We only ever need one devinfo per handle. So allocate it outside of
looping over the filesystem modules rather than doing a malloc + free
each time through the loop. In addition, nothing changes from loop to
loop, so setup the new devinfo outside the loop as well.
Modified:
head/stand/efi/boot1/boot1.c
Modified: head/stand/efi/boot1/boot1.c
==============================================================================
--- head/stand/efi/boot1/boot1.c Mon May 6 18:38:46 2019
(r347193)
+++ head/stand/efi/boot1/boot1.c Mon May 6 18:39:22 2019
(r347194)
@@ -264,24 +264,24 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, B
*preferred = efi_devpath_match(imgpath, devpath);
/* Run through each module, see if it can load this partition */
+ devinfo = malloc(sizeof(*devinfo));
+ if (devinfo == NULL) {
+ DPRINTF("\nFailed to allocate devinfo\n");
+ return (EFI_UNSUPPORTED);
+ }
+ devinfo->dev = blkio;
+ devinfo->devpath = devpath;
+ devinfo->devhandle = h;
+ devinfo->preferred = *preferred;
+ devinfo->next = NULL;
+
for (i = 0; i < NUM_BOOT_MODULES; i++) {
- devinfo = malloc(sizeof(*devinfo));
- if (devinfo == NULL) {
- DPRINTF("\nFailed to allocate devinfo\n");
- break;
- }
- devinfo->dev = blkio;
- devinfo->devpath = devpath;
- devinfo->devhandle = h;
devinfo->devdata = NULL;
- devinfo->preferred = *preferred;
- devinfo->next = NULL;
-
status = boot_modules[i]->probe(devinfo);
if (status == EFI_SUCCESS)
return (EFI_SUCCESS);
- free(devinfo);
}
+ free(devinfo);
return (EFI_UNSUPPORTED);
}
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"