Skip to contentSkip to conversation

x86: boot/compressed fix resource leak

PATCH New Andre Bartke 1 participant 1 message May 31, 2011 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: boot/compressed fix resource leak

In case fread() fails, we should call fclose and release the resource properly. Also while at it, fixed brace coding style issue.

---
 arch/x86/boot/compressed/mkpiggy.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
arch/x86/boot/compressed/mkpiggy.c +2 -3
index 46a8238..33b85be 100644
@@ -58,13 +58,12 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
-
-	if (fseek(f, -4L, SEEK_END)) {
+	if (fseek(f, -4L, SEEK_END))
 		perror(argv[1]);
-	}
 
 	if (fread(&olen, sizeof(olen), 1, f) != 1) {
 		perror(argv[1]);
+		fclose(f);
 		return 1;
 	}
 
Signature · 1 line
1.7.5.2