diff options
author | Artur Wojcik <artur.wojcik@intel.com> | 2009-12-10 20:03:40 +0100 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2009-12-10 20:03:40 +0100 |
commit | 922f66a935df8e6b3b66073a89c47c68c2e8cbe3 (patch) | |
tree | b45ada133d95347e9fb7c02b0624cd0368cd729a /probe_roms.c | |
parent | Fix for buffer overflow defect. (diff) | |
download | mdadm-922f66a935df8e6b3b66073a89c47c68c2e8cbe3.tar.xz mdadm-922f66a935df8e6b3b66073a89c47c68c2e8cbe3.zip |
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>
Diffstat (limited to 'probe_roms.c')
-rw-r--r-- | probe_roms.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/probe_roms.c b/probe_roms.c index a9a86388..0f0ffbcc 100644 --- a/probe_roms.c +++ b/probe_roms.c @@ -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; } |