Plug fd leaks

This commit is contained in:
Kevin Lo 2011-11-23 10:27:18 +00:00
parent 85df379184
commit de028133d4
3 changed files with 4 additions and 0 deletions

View File

@ -370,6 +370,7 @@ load_dsdt(const char *dsdtfile)
}
if (fstat(fd, &sb) == -1) {
perror("fstat");
close(fd);
return (-1);
}
code = mmap(NULL, (size_t)sb.st_size, PROT_READ, MAP_PRIVATE, fd, (off_t)0);

View File

@ -221,6 +221,7 @@ main(int argc, char *argv[])
free(firmware);
firmware = NULL;
fclose(firmware_file);
return (0);
}

View File

@ -330,10 +330,12 @@ read_mbr(const char *disk, u_int8_t **mbr, int check_version)
err(1, "%s", disk);
if (n != mbr_size)
errx(1, "%s: short read", disk);
close(fd);
return (mbr_size);
}
*mbr = malloc(sizeof(buf));
memcpy(*mbr, buf, sizeof(buf));
close(fd);
return sizeof(buf);
}