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

Commit b989d564 authored by Manoj Prabhu B's avatar Manoj Prabhu B
Browse files

diag: Add mutex protection while closing diag channels



Add mutex protection while opening and closing diag channels to
fix the race conditions.

Change-Id: I26bc5e4061bd86f112993ac16789a95e6d6e01c8
Signed-off-by: default avatarSreelakshmi Gownipalli <sgownipa@codeaurora.org>
Signed-off-by: default avatarManoj Prabhu B <bmanoj@codeaurora.org>
parent 316c074a
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -848,7 +848,7 @@ int diagfwd_channel_open(struct diagfwd_info *fwd_info)
			 __func__, fwd_info->peripheral, fwd_info->type);
		return 0;
	}

	mutex_lock(&driver->diagfwd_channel_mutex[fwd_info->peripheral]);
	fwd_info->ch_open = 1;
	diagfwd_buffers_init(fwd_info);
	diagfwd_write_buffers_init(fwd_info);
@@ -866,7 +866,7 @@ int diagfwd_channel_open(struct diagfwd_info *fwd_info)
		if (fwd_info->p_ops && fwd_info->p_ops->open)
			fwd_info->p_ops->open(fwd_info->ctxt);
	}

	mutex_unlock(&driver->diagfwd_channel_mutex[fwd_info->peripheral]);
	return 0;
}

@@ -877,6 +877,7 @@ int diagfwd_channel_close(struct diagfwd_info *fwd_info)
	if (!fwd_info)
		return -EIO;

	mutex_lock(&driver->diagfwd_channel_mutex[fwd_info->peripheral]);
	fwd_info->ch_open = 0;
	if (fwd_info && fwd_info->c_ops && fwd_info->c_ops->close)
		fwd_info->c_ops->close(fwd_info);
@@ -892,7 +893,7 @@ int diagfwd_channel_close(struct diagfwd_info *fwd_info)
	}
	DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "p: %d t: %d considered closed\n",
		 fwd_info->peripheral, fwd_info->type);

	mutex_unlock(&driver->diagfwd_channel_mutex[fwd_info->peripheral]);
	return 0;
}