Fix possible memory leak in peripheral_pwm_close 00/130200/2
authorHyeongsik Min <hyeongsik.min@samsung.com>
Fri, 19 May 2017 10:22:11 +0000 (19:22 +0900)
committerHyeongsik Min <hyeongsik.min@samsung.com>
Mon, 22 May 2017 10:53:15 +0000 (19:53 +0900)
Free pwm handle regardless of return value of
peripheral_gdbus_pwm_close().

Change-Id: Iaaa85b757f96851eac186c11efbdd8fa8e32bb98
Signed-off-by: Hyeongsik Min <hyeongsik.min@samsung.com>
src/peripheral_pwm.c

index 607c8f8dc1625b5e6693298b69dfa09f073efec4..7e98766ce6935deec3c2fca67191c9ec9b874c31 100644 (file)
@@ -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;
 }