Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ebb3727 authored by Christian Gromm's avatar Christian Gromm Committed by Greg Kroah-Hartman
Browse files

staging: most: dim2-hdm: fix race condition when closing a channel



This patch fixes race between the function poison_channel that clears
the state is_initialized and the tasklet function dim2_tasklet_fn that
checks the state is_initialized.

Signed-off-by: default avatarAndrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: default avatarChristian Gromm <christian.gromm@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 908614be
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -705,12 +705,14 @@ static int poison_channel(struct most_interface *most_iface, int ch_idx)
	if (!hdm_ch->is_initialized)
	if (!hdm_ch->is_initialized)
		return -EPERM;
		return -EPERM;


	tasklet_disable(&dim2_tasklet);
	spin_lock_irqsave(&dim_lock, flags);
	spin_lock_irqsave(&dim_lock, flags);
	hal_ret = dim_destroy_channel(&hdm_ch->ch);
	hal_ret = dim_destroy_channel(&hdm_ch->ch);
	hdm_ch->is_initialized = false;
	hdm_ch->is_initialized = false;
	if (ch_idx == dev->atx_idx)
	if (ch_idx == dev->atx_idx)
		dev->atx_idx = -1;
		dev->atx_idx = -1;
	spin_unlock_irqrestore(&dim_lock, flags);
	spin_unlock_irqrestore(&dim_lock, flags);
	tasklet_enable(&dim2_tasklet);
	if (hal_ret != DIM_NO_ERROR) {
	if (hal_ret != DIM_NO_ERROR) {
		pr_err("HAL Failed to close channel %s\n", hdm_ch->name);
		pr_err("HAL Failed to close channel %s\n", hdm_ch->name);
		ret = -EFAULT;
		ret = -EFAULT;