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

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

Merge "diag: Save the correct task pointer while registering dci client"

parents 52a54f6b 76e34f80
Loading
Loading
Loading
Loading
+22 −6
Original line number Diff line number Diff line
@@ -2996,6 +2996,8 @@ int diag_dci_register_client(struct diag_dci_reg_tbl_t *reg_entry)
	int i, err = 0;
	struct diag_dci_client_tbl *new_entry = NULL;
	struct diag_dci_buf_peripheral_t *proc_buf = NULL;
	struct pid *pid_struct = NULL;
	struct task_struct *task_s = NULL;

	if (!reg_entry)
		return DIAG_DCI_NO_REG;
@@ -3011,14 +3013,25 @@ int diag_dci_register_client(struct diag_dci_reg_tbl_t *reg_entry)
	if (driver->num_dci_client >= MAX_DCI_CLIENTS)
		return DIAG_DCI_NO_REG;

	pid_struct = find_get_pid(current->tgid);
	if (!pid_struct)
		return DIAG_DCI_NO_REG;
	task_s = get_pid_task(pid_struct, PIDTYPE_PID);
	if (!task_s) {
		put_pid(pid_struct);
		return DIAG_DCI_NO_REG;
	}
	new_entry = kzalloc(sizeof(struct diag_dci_client_tbl), GFP_KERNEL);
	if (!new_entry)
	if (!new_entry) {
		put_pid(pid_struct);
		put_task_struct(task_s);
		return DIAG_DCI_NO_REG;
	}

	mutex_lock(&driver->dci_mutex);
	get_task_struct(task_s);

	get_task_struct(current);
	new_entry->client = current;
	mutex_lock(&driver->dci_mutex);
	new_entry->client = task_s;
	new_entry->tgid = current->tgid;
	new_entry->client_info.notification_list =
				reg_entry->notification_list;
@@ -3108,7 +3121,8 @@ int diag_dci_register_client(struct diag_dci_reg_tbl_t *reg_entry)
		diag_update_proc_vote(DIAG_PROC_DCI, VOTE_UP, reg_entry->token);
	queue_work(driver->diag_real_time_wq, &driver->diag_real_time_work);
	mutex_unlock(&driver->dci_mutex);

	put_pid(pid_struct);
	put_task_struct(task_s);
	return reg_entry->client_id;

fail_alloc:
@@ -3145,8 +3159,10 @@ int diag_dci_register_client(struct diag_dci_reg_tbl_t *reg_entry)
		kfree(new_entry);
		new_entry = NULL;
	}
	put_task_struct(current);
	mutex_unlock(&driver->dci_mutex);
	put_task_struct(task_s);
	put_task_struct(task_s);
	put_pid(pid_struct);
	return DIAG_DCI_NO_REG;
}