summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2016-11-13 13:03:50 +0100
committerMichael W <baddaemon87@gmail.com>2016-11-13 13:03:50 +0100
commit656154a5b4127370f7317852e224a9121c6beed3 (patch)
treea68d24c05e65a8400e8074067e7ec6a118edc533
parent85f740eb6ddaab64983085fb0c7bb8ae850ef828 (diff)
downloadsystem_core-656154a5b4127370f7317852e224a9121c6beed3.zip
system_core-656154a5b4127370f7317852e224a9121c6beed3.tar.gz
system_core-656154a5b4127370f7317852e224a9121c6beed3.tar.bz2
init: Fix possible open file pointer
In error case the file is not closed properly. Add close() before return Change-Id: Ie1755987859a576045c786105404957d94f0b39d
-rw-r--r--init/init.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/init/init.cpp b/init/init.cpp
index 58d7d34..8ea42ca 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -1012,8 +1012,10 @@ static int charging_mode_booting(void) {
if (f < 0)
return 0;
- if (1 != read(f, (void *)&cmb,1))
+ if (1 != read(f, (void *)&cmb,1)) {
+ close(f);
return 0;
+ }
close(f);
return ('1' == cmb);