From: Dongwoo Lee Date: Tue, 11 Jul 2017 05:54:57 +0000 (+0900) Subject: pass: Put resource properly to prevent memory leak X-Git-Tag: submit/tizen/20170719.015733~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F10%2F138110%2F3;p=platform%2Fcore%2Fsystem%2Fpass.git pass: Put resource properly to prevent memory leak There are two cases which can cause memory leak during pass init/exit: 1. When resource initialization is failed, it just skips that resource without putting it. 2. In the case of failure while freeing resources, it is also skipped putting that resource. To prevent memory leak, the resource will be put on both cases. Change-Id: I4008b7785e0dbbc318b38eb573bf739e0a848b6c Signed-off-by: Dongwoo Lee --- diff --git a/src/pass/pass.c b/src/pass/pass.c index 8cf368f..dfea1d0 100644 --- a/src/pass/pass.c +++ b/src/pass/pass.c @@ -251,6 +251,11 @@ static int pass_init_done(void *data, void *user_data) if (ret < 0) { _E("Cannot initialize the pass '%s' resource (%d)\n", cdata->res_name, ret); + + ret = pass_put_resource(pass_res); + if (ret < 0) + _E("Cannot put the pass '%s' resource (%d)\n", + cdata->res_name, ret); continue; } } @@ -267,11 +272,9 @@ static int pass_exit_done(void) struct pass_conf_data *cdata = &g_pass.res[i].cdata; ret = pass_resource_exit(pass_res); - if (ret < 0) { + if (ret < 0) _E("Cannot exit the pass '%s' resource (%d)\n", cdata->res_name, ret); - continue; - } ret = pass_put_resource(pass_res); if (ret < 0) {