Date: Mon, 6 May 2019 18:39:22 +0000 (UTC) From: Warner Losh <imp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347194 - head/stand/efi/boot1 Message-ID: <201905061839.x46IdM7W082753@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905061839.x46IdM7W082753>