From 3d691038bc818f64ffbdf2d9eed83bf5db7ebebd Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 5 Aug 2022 09:29:26 -0500 Subject: [PATCH] station: Fix memory leak Make sure that the known frequency set is always cleaned up on error. Fixes: bb604b92f18c ("station: fallback to periodic scan if regdom unset") --- src/station.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/station.c b/src/station.c index 6b5cbb14..c5dfc48e 100644 --- a/src/station.c +++ b/src/station.c @@ -1354,7 +1354,7 @@ static void station_quick_scan_destroy(void *userdata) static int station_quick_scan_trigger(struct station *station) { - struct scan_freq_set *known_freq_set; + _auto_(scan_freq_set_free) struct scan_freq_set *known_freq_set = NULL; bool known_6ghz; const struct scan_freq_set *disabled = wiphy_get_disabled_freqs( station->wiphy); @@ -1385,7 +1385,6 @@ static int station_quick_scan_trigger(struct station *station) return -ENOTSUP; if (!wiphy_constrain_freq_set(station->wiphy, known_freq_set)) { - scan_freq_set_free(known_freq_set); return -ENOTSUP; } @@ -1394,8 +1393,6 @@ static int station_quick_scan_trigger(struct station *station) station_quick_scan_triggered, station_quick_scan_results, station_quick_scan_destroy); - scan_freq_set_free(known_freq_set); - if (!station->quick_scan_id) return -EIO;