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

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

Merge "diag: dci: Validate dci client entries prior to access"

parents 79a01506 83e726e0
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -2130,8 +2130,26 @@ struct diag_dci_client_tbl *dci_lookup_client_entry_pid(int tgid)
{
	struct list_head *start, *temp;
	struct diag_dci_client_tbl *entry = NULL;
	struct pid *pid_struct = NULL;
	struct task_struct *task_s = NULL;

	list_for_each_safe(start, temp, &driver->dci_client_list) {
		entry = list_entry(start, struct diag_dci_client_tbl, track);
		pid_struct = find_get_pid(entry->tgid);
		if (!pid_struct) {
			DIAG_LOG(DIAG_DEBUG_DCI,
				"diag: valid pid doesn't exist for pid = %d\n",
				entry->tgid);
			continue;
		}
		task_s = get_pid_task(pid_struct, PIDTYPE_PID);
		if (!task_s) {
			DIAG_LOG(DIAG_DEBUG_DCI,
				"diag: valid task doesn't exist for pid = %d\n",
				entry->tgid);
			continue;
		}
		if (task_s == entry->client)
			if (entry->client->tgid == tgid)
				return entry;
	}