Fix some svace issues for memory leak and checking return value
[platform/core/connectivity/net-config.git] / src / wifi-power.c
index 71e9530..947716f 100755 (executable)
@@ -307,11 +307,19 @@ static void __netconfig_set_wifi_bssid(void)
                return;
        }
 
-       fseek(fp, 0L, SEEK_SET);
-       rv = fscanf(fp, "%17s", bssid);
+       rv = fseek(fp, 0L, SEEK_SET);
+       if (rv != 0) {
+               ERR("Fail to seek file");
+               fclose(fp);
+               return;
+       }
 
-       if (rv < 0)
+       rv = fscanf(fp, "%17s", bssid);
+       if (rv < 0) {
                ERR("Fail to read bssid");
+               fclose(fp);
+               return;
+       }
 
        netconfig_set_vconf_str(VCONF_WIFI_BSSID_ADDRESS, bssid);