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

Commit 05396f3e authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "diag: Prevent switching mode for non mdlog process"

parents c3cec2a2 8565697d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -656,6 +656,7 @@ struct diagchar_dev {
	int usb_connected;
#endif
	int pcie_connected;
	int pcie_switch_pid;
	struct workqueue_struct *diag_wq;
	struct work_struct diag_drain_work;
	struct work_struct update_user_clients;
+24 −8
Original line number Diff line number Diff line
@@ -460,15 +460,19 @@ static void diag_close_logging_process(const int pid)
	session_info = diag_md_session_get_pid(pid);
	if (!session_info) {
		mutex_unlock(&driver->md_session_lock);
		if (driver->pcie_transport_def == DIAG_ROUTE_TO_PCIE)
		mutex_lock(&driver->diagchar_mutex);
		if (driver->pcie_switch_pid == pid) {
			if (driver->pcie_transport_def ==
				DIAG_ROUTE_TO_PCIE)
				params.req_mode = PCIE_MODE;
			else
				params.req_mode = USB_MODE;
			params.mode_param = 0;
			params.pd_mask = 0;
			params.peripheral_mask = DIAG_CON_ALL;
		mutex_lock(&driver->diagchar_mutex);
			diag_switch_logging(&params);
			driver->pcie_switch_pid = 0;
		}
		mutex_unlock(&driver->diagchar_mutex);
		return;
	}
@@ -1895,6 +1899,17 @@ static int diag_switch_logging(struct diag_logging_mode_param_t *param)
	}
	driver->logging_mode = new_mode;
	driver->logging_mask = peripheral_mask;
	if (((curr_mode == DIAG_PCIE_MODE && new_mode == DIAG_USB_MODE) ||
		(curr_mode == DIAG_USB_MODE && new_mode == DIAG_PCIE_MODE)) &&
		!driver->pcie_switch_pid) {
		/*
		 * Store the pid of process affecting switch
		 * from USB to PCIE or vice versa to help
		 * close only this process while closing
		 * logging process.
		 */
		driver->pcie_switch_pid = current->tgid;
	}
	if (new_mode == DIAG_PCIE_MODE) {
		driver->transport_set = DIAG_ROUTE_TO_PCIE;
		diagmem_setsize(POOL_TYPE_MUX_APPS, itemsize_pcie_apps,
@@ -4204,6 +4219,7 @@ static int __init diagchar_init(void)
	driver->mask_check = 0;
	driver->in_busy_pktdata = 0;
	driver->in_busy_dcipktdata = 0;
	driver->pcie_switch_pid = 0;
	driver->rsp_buf_ctxt = SET_BUF_CTXT(APPS_DATA, TYPE_CMD, 1);
	hdlc_data.ctxt = SET_BUF_CTXT(APPS_DATA, TYPE_DATA, 1);
	hdlc_data.len = 0;