From: Hyeongsik Min Date: Fri, 19 May 2017 10:22:11 +0000 (+0900) Subject: Fix possible memory leak in peripheral_pwm_close X-Git-Tag: submit/tizen/20170602.034029~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=beba91c7725e702664b95039532771ee894ee7ca;p=platform%2Fcore%2Fapi%2Fperipheral-io.git Fix possible memory leak in peripheral_pwm_close Free pwm handle regardless of return value of peripheral_gdbus_pwm_close(). Change-Id: Iaaa85b757f96851eac186c11efbdd8fa8e32bb98 Signed-off-by: Hyeongsik Min --- diff --git a/src/peripheral_pwm.c b/src/peripheral_pwm.c index 607c8f8..7e98766 100644 --- a/src/peripheral_pwm.c +++ b/src/peripheral_pwm.c @@ -59,13 +59,11 @@ int peripheral_pwm_close(peripheral_pwm_h pwm) if (pwm == NULL) return PERIPHERAL_ERROR_INVALID_PARAMETER; - ret = peripheral_gdbus_pwm_close(pwm); - pwm_proxy_deinit(); + if ((ret = peripheral_gdbus_pwm_close(pwm)) < 0) + _E("Failed to close PWM device, continuing anyway"); - if (ret == PERIPHERAL_ERROR_NONE) { - free(pwm); - pwm = NULL; - } + pwm_proxy_deinit(); + free(pwm); return ret; }