Handle the case that best_bss is NULL 78/233278/2 submit/tizen/20200513.103127
authorCheoleun Moon <chleun.moon@samsung.com>
Wed, 13 May 2020 10:19:08 +0000 (19:19 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Wed, 13 May 2020 10:22:33 +0000 (19:22 +0900)
Change-Id: I4a813bb3327f400df0050a850ec72fa8b99c870b
Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
gsupplicant/supplicant.c

index b16625c..36625d0 100755 (executable)
@@ -2459,16 +2459,30 @@ static char *create_group(struct g_supplicant_bss *bss)
        return g_string_free(str, FALSE);
 }
 
+static void update_network_with_best_bss(GSupplicantNetwork *network,
+               struct g_supplicant_bss *best_bss)
+{
+       network->signal = best_bss->signal;
+       network->frequency = best_bss->frequency;
+       network->best_bss = best_bss;
+}
+
 static bool update_best_bss(GSupplicantNetwork *network,
                struct g_supplicant_bss *bss, struct g_supplicant_bss *best_bss)
 {
        int score_new;
        int score_best;
 
+       if (network->best_bss == NULL) {
+               update_network_with_best_bss(network, bss);
+               return true;
+       }
+
        score_new = calculate_score(
                compare_bssid(bss->bssid, network->last_connected_bssid),
                get_assoc_reject_cnt(network->assoc_reject_table, bss->bssid),
                bss->frequency, bss->signal);
+
        score_best = calculate_score(
                compare_bssid(network->best_bss->bssid, network->last_connected_bssid),
                get_assoc_reject_cnt(network->assoc_reject_table, network->best_bss->bssid),
@@ -2479,9 +2493,7 @@ static bool update_best_bss(GSupplicantNetwork *network,
                        MAC2STR(bss->bssid), score_new,
                        MAC2STR(network->best_bss->bssid), score_best);
 
-               network->signal = bss->signal;
-               network->frequency = bss->frequency;
-               network->best_bss = bss;
+               update_network_with_best_bss(network, bss);
 
                SUPPLICANT_DBG("Update best BSS for %s", network->name);