common: fix minor issues 60/88860/3 accepted/tizen/common/20160921.162506 accepted/tizen/ivi/20160921.232950 accepted/tizen/mobile/20160921.232939 accepted/tizen/tv/20160921.232944 accepted/tizen/wearable/20160921.232934 submit/tizen/20160921.044915
authortaeyoung <ty317.kim@samsung.com>
Wed, 21 Sep 2016 03:42:58 +0000 (12:42 +0900)
committerJung <pr.jung@samsung.com>
Wed, 21 Sep 2016 04:45:58 +0000 (21:45 -0700)
- memory leak
- uninitialized variable
- memory release sequence

Change-Id: I9a4271bf4a83029e5ce4dd9f38be1cdb2fa7682f
Signed-off-by: taeyoung <ty317.kim@samsung.com>
src/libdeviced/usbhost.c
src/usbhost/usb-host.c

index cf00e69..1cb0d1d 100644 (file)
@@ -71,6 +71,7 @@ static int register_edbus_signal_handler(const char *path, const char *interface
        handler = calloc(1, sizeof(*handler));
        if (!handler) {
                _E("No memory");
+               ret = -1;
                goto out;
        }
        handler->name = name;
index 83e2638..16d65df 100644 (file)
@@ -609,9 +609,8 @@ static int store_policy(void)
 
        fd = open(POLICY_FILEPATH, O_WRONLY | O_CREAT, 0664);
        if (fd < 0) {
-               ret = -errno;
                _E("Could not open policy file for writing: %m");
-               goto out;
+               return -errno;
        }
 
        DD_LIST_FOREACH(access_list, elem, entry) {
@@ -684,8 +683,8 @@ static int read_policy(void)
                                value_str);
                if (ret == EOF) {
                        _E("Error reading line: %m");
-                       free(entry);
                        free(entry->creds.sec_label);
+                       free(entry);
                        goto out;
                }