mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-26 13:05:18 +01:00
libefi: efipart.c should use calloc()
The device specific *_add functions are using malloc() + memset, should use calloc instead.
This commit is contained in:
parent
59fcc285f4
commit
cfe103a2ac
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323886
@ -198,12 +198,11 @@ efipart_fdinfo_add(EFI_HANDLE handle, uint32_t uid, EFI_DEVICE_PATH *devpath)
|
||||
{
|
||||
pdinfo_t *fd;
|
||||
|
||||
fd = malloc(sizeof(pdinfo_t));
|
||||
fd = calloc(1, sizeof(pdinfo_t));
|
||||
if (fd == NULL) {
|
||||
printf("Failed to register floppy %d, out of memory\n", uid);
|
||||
return (ENOMEM);
|
||||
}
|
||||
memset(fd, 0, sizeof(pdinfo_t));
|
||||
STAILQ_INIT(&fd->pd_part);
|
||||
|
||||
fd->pd_unit = uid;
|
||||
@ -272,12 +271,11 @@ efipart_cdinfo_add(EFI_HANDLE handle, EFI_HANDLE alias,
|
||||
unit++;
|
||||
}
|
||||
|
||||
cd = malloc(sizeof(pdinfo_t));
|
||||
cd = calloc(1, sizeof(pdinfo_t));
|
||||
if (cd == NULL) {
|
||||
printf("Failed to add cd %d, out of memory\n", unit);
|
||||
return (ENOMEM);
|
||||
}
|
||||
memset(cd, 0, sizeof(pdinfo_t));
|
||||
STAILQ_INIT(&cd->pd_part);
|
||||
|
||||
cd->pd_handle = handle;
|
||||
@ -385,12 +383,11 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE part_handle)
|
||||
if (node == NULL)
|
||||
return (ENOENT); /* This should not happen. */
|
||||
|
||||
pd = malloc(sizeof(pdinfo_t));
|
||||
pd = calloc(1, sizeof(pdinfo_t));
|
||||
if (pd == NULL) {
|
||||
printf("Failed to add disk, out of memory\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
memset(pd, 0, sizeof(pdinfo_t));
|
||||
STAILQ_INIT(&pd->pd_part);
|
||||
|
||||
STAILQ_FOREACH(hd, &hdinfo, pd_link) {
|
||||
@ -417,12 +414,11 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE part_handle)
|
||||
hd->pd_devpath = disk_devpath;
|
||||
STAILQ_INSERT_TAIL(&hdinfo, hd, pd_link);
|
||||
|
||||
pd = malloc(sizeof(pdinfo_t));
|
||||
pd = calloc(1, sizeof(pdinfo_t));
|
||||
if (pd == NULL) {
|
||||
printf("Failed to add partition, out of memory\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
memset(pd, 0, sizeof(pdinfo_t));
|
||||
STAILQ_INIT(&pd->pd_part);
|
||||
|
||||
/* Add the partition. */
|
||||
@ -456,12 +452,11 @@ efipart_hdinfo_add_filepath(EFI_HANDLE disk_handle)
|
||||
if (node == NULL)
|
||||
return (ENOENT); /* This should not happen. */
|
||||
|
||||
pd = malloc(sizeof(pdinfo_t));
|
||||
pd = calloc(1, sizeof(pdinfo_t));
|
||||
if (pd == NULL) {
|
||||
printf("Failed to add disk, out of memory\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
memset(pd, 0, sizeof(pdinfo_t));
|
||||
STAILQ_INIT(&pd->pd_part);
|
||||
last = STAILQ_LAST(&hdinfo, pdinfo, pd_link);
|
||||
if (last != NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user