[PATCH] bios: mtrr: free mtrr_list on file open error
Colin King
colin.king at canonical.com
Mon May 6 22:20:04 UTC 2013
From: Colin Ian King <colin.king at canonical.com>
Free mtrr_list on file open error to fix resource leak bug.
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/bios/mtrr/mtrr.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c
index 284d153..38f89fb 100644
--- a/src/bios/mtrr/mtrr.c
+++ b/src/bios/mtrr/mtrr.c
@@ -88,8 +88,10 @@ static int get_mtrrs(void)
if ((mtrr_list = fwts_list_new()) == NULL)
return FWTS_ERROR;
- if ((fp = fopen("/proc/mtrr", "r")) == NULL)
+ if ((fp = fopen("/proc/mtrr", "r")) == NULL) {
+ fwts_list_free(mtrr_list, free);
return FWTS_ERROR;
+ }
while (!feof(fp)) {
char *ptr1, *ptr2;
--
1.8.1.2
More information about the fwts-devel
mailing list