diff options
author | Prarit Bhargava <prarit@redhat.com> | 2016-05-16 11:19:11 -0400 |
---|---|---|
committer | Andi Kleen <ak@linux.intel.com> | 2016-05-16 13:43:58 -0700 |
commit | b2d6f0c4e762e28d877a8e0e744a6946cd1cae4f (patch) | |
tree | 89407726356adc16eba2ff75d914d9f68843073b | |
parent | 43656685015f3ec46dfb65fb03342bc57dace5a0 (diff) | |
download | mcelog-b2d6f0c4e762e28d877a8e0e744a6946cd1cae4f.tar.gz |
mcelog: Fix file descriptor leak in domsr()
This patch fixes a file descriptor leak in domsr(). fd should be closed
on errors.
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
-rw-r--r-- | msr.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -25,19 +25,20 @@ static void domsr(int cpu, int msr, int bit) } if (pread(fd, &data, sizeof data, msr) != sizeof data) { SYSERRprintf("Cannot read MSR_ERROR_CONTROL from %s\n", fpath); - return; + goto out; } data |= bit; if (pwrite(fd, &data, sizeof data, msr) != sizeof data) { SYSERRprintf("Cannot write MSR_ERROR_CONTROL to %s\n", fpath); - return; + goto out; } if (pread(fd, &data, sizeof data, msr) != sizeof data) { SYSERRprintf("Cannot re-read MSR_ERROR_CONTROL from %s\n", fpath); - return; + goto out; } if ((data & bit) == 0) Lprintf("No DIMM detection available on cpu %d (normal in virtual environments)\n", cpu); +out: close(fd); } |