init: fix memory leaks
It's possible that node is not freed before return.
Test: make WITH_TIDY=1 mmma system/core/init
Change-Id: I648eea9dda006d2b2239e169785190817ad31352
diff --git a/init/devices.cpp b/init/devices.cpp
index 1a6912f..ff449c9 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -109,13 +109,18 @@
return -ENOMEM;
node->dp.name = strdup(name);
- if (!node->dp.name)
+ if (!node->dp.name) {
+ free(node);
return -ENOMEM;
+ }
if (attr) {
node->dp.attr = strdup(attr);
- if (!node->dp.attr)
+ if (!node->dp.attr) {
+ free(node->dp.name);
+ free(node);
return -ENOMEM;
+ }
}
node->dp.perm = perm;