Fix for resource leak on error path.

Make sure opened file descriptors are cleaned up
in the exit path when error occured.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
Artur Wojcik 2009-12-10 12:03:40 -07:00 committed by Dan Williams
parent 5dbb8c8d76
commit 922f66a935
1 changed files with 5 additions and 3 deletions

View File

@ -80,7 +80,7 @@ void probe_roms_exit(void)
int probe_roms_init(unsigned long align)
{
int fd;
int fd = -1;
int rc = 0;
/* valid values are 2048 and 512. 512 is for PCI-3.0 compliant
@ -107,9 +107,11 @@ int probe_roms_init(unsigned long align)
if (rc == 0)
rom_fd = fd;
else
else {
if (fd >= 0)
close(fd);
probe_roms_exit();
}
return rc;
}