mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
Merge branch 'bugfix/eloop_timer_crash_v5.0' into 'release/v5.0'
wpa_supplicant: Validate eloop struct before deleting it (v5.0) See merge request espressif/esp-idf!20846
This commit is contained in:
@ -140,16 +140,31 @@ overflow:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool timeout_exists(struct eloop_timeout *old)
|
||||||
|
{
|
||||||
|
struct eloop_timeout *timeout, *prev;
|
||||||
|
dl_list_for_each_safe(timeout, prev, &eloop.timeout,
|
||||||
|
struct eloop_timeout, list) {
|
||||||
|
if (old == timeout)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static void eloop_remove_timeout(struct eloop_timeout *timeout)
|
static void eloop_remove_timeout(struct eloop_timeout *timeout)
|
||||||
{
|
{
|
||||||
|
bool timeout_present = false;
|
||||||
ELOOP_LOCK();
|
ELOOP_LOCK();
|
||||||
dl_list_del(&timeout->list);
|
/* Make sure timeout still exists(Another context may have deleted this) */
|
||||||
|
timeout_present = timeout_exists(timeout);
|
||||||
|
if (timeout_present)
|
||||||
|
dl_list_del(&timeout->list);
|
||||||
ELOOP_UNLOCK();
|
ELOOP_UNLOCK();
|
||||||
os_free(timeout);
|
if (timeout_present)
|
||||||
|
os_free(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef ELOOP_DEBUG
|
#ifdef ELOOP_DEBUG
|
||||||
int eloop_cancel_timeout_debug(eloop_timeout_handler handler, void *eloop_data,
|
int eloop_cancel_timeout_debug(eloop_timeout_handler handler, void *eloop_data,
|
||||||
void *user_data, const char *func, int line)
|
void *user_data, const char *func, int line)
|
||||||
|
Reference in New Issue
Block a user