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

Commit 1d69007b authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "diag: Avoid race while closing and opening mhi channels"

parents 28682f34 7f14769d
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -278,9 +278,11 @@ static int __mhi_close(struct diag_mhi_info *mhi_info, int close_flag)
	cancel_work_sync(&mhi_info->read_done_work);
	flush_workqueue(mhi_info->mhi_wq);

	if (close_flag == CLOSE_CHANNELS)
	if (close_flag == CLOSE_CHANNELS) {
		mutex_lock(&mhi_info->ch_mutex);
		mhi_unprepare_from_transfer(mhi_info->mhi_dev);

		mutex_unlock(&mhi_info->ch_mutex);
	}
	mhi_buf_tbl_clear(mhi_info);
	diag_remote_dev_close(mhi_info->dev_id);
	return 0;
@@ -334,7 +336,9 @@ static int __mhi_open(struct diag_mhi_info *mhi_info, int token, int open_flag)
		if ((atomic_read(&(mhi_info->read_ch.opened))) &&
			(atomic_read(&(mhi_info->write_ch.opened))))
			return 0;
		mutex_lock(&mhi_info->ch_mutex);
		err = mhi_prepare_for_transfer(mhi_info->mhi_dev);
		mutex_unlock(&mhi_info->ch_mutex);
		if (err) {
			pr_err("diag: In %s, unable to open ch, err: %d\n",
				__func__, err);
@@ -850,6 +854,7 @@ int diag_mhi_init(void)
			spin_lock_init(&mhi_info->lock);
			spin_lock_init(&mhi_info->read_ch.lock);
			spin_lock_init(&mhi_info->write_ch.lock);
			mutex_init(&mhi_info->ch_mutex);
			INIT_LIST_HEAD(&mhi_info->read_ch.buf_tbl);
			INIT_LIST_HEAD(&mhi_info->write_ch.buf_tbl);
			atomic_set(&(mhi_info->read_ch.opened), 0);
+1 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ struct diag_mhi_info {
	wait_queue_head_t mhi_wait_q;
	struct diag_mhi_ch_t read_ch;
	struct diag_mhi_ch_t write_ch;
	struct mutex ch_mutex;
	spinlock_t lock;
};