Skip to content

A data race bug #13795

@ryancaicse

Description

@ryancaicse

Hi, lock gx_stop_dev_thread is used to protect gx_stop_dev_thread. However, while(!gx_stop_dev_thread) at Line 128 in the method gx_devthread is not protected by the lock.

static void gx_devthread(void *a)
{
unsigned i;
while (!gx_stop_dev_thread)
{
slock_lock(gx_device_mutex);
for (i = 0; i < GX_DEVICE_END; i++)
{
if (gx_devices[i].mounted)
{
if (!gx_devices[i].interface->isInserted())
{
char n[8] = {0};
gx_devices[i].mounted = false;
snprintf(n, sizeof(n), "%s:", gx_devices[i].name);
fatUnmount(n);
}
}
else if (gx_devices[i].interface->startup() && gx_devices[i].interface->isInserted())
gx_devices[i].mounted = fatMountSimple(gx_devices[i].name, gx_devices[i].interface);
}
slock_unlock(gx_device_mutex);
slock_lock(gx_device_cond_mutex);
scond_wait_timeout(gx_device_cond, gx_device_cond_mutex, 1000000);
slock_unlock(gx_device_cond_mutex);
}
}

static void frontend_gx_deinit(void *data)
{
(void)data;
#if defined(HW_RVL) && !defined(IS_SALAMANDER)
slock_lock(gx_device_cond_mutex);
gx_stop_dev_thread = true;
slock_unlock(gx_device_cond_mutex);
scond_signal(gx_device_cond);
sthread_join(gx_device_thread);
#endif
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions