From beba91c7725e702664b95039532771ee894ee7ca Mon Sep 17 00:00:00 2001 From: Hyeongsik Min Date: Fri, 19 May 2017 19:22:11 +0900 Subject: [PATCH] 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 --- src/peripheral_pwm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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; } -- 2.7.4