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

Commit 3f4178bf authored by Manoj Prabhu B's avatar Manoj Prabhu B
Browse files

diag: Fix for possible stale task entries



The task entries were cleared while closing the
md session and hence are stale when notifying the client
with the task entries.
This patch provides the protection on md session and
also checks for the session pid and task pid being same.

CRs-Fixed: 1008137
Change-Id: I999db2865d10464c7f1ab4a5a940d23c725ac033
Signed-off-by: default avatarManoj Prabhu B <bmanoj@codeaurora.org>
parent e17a72ad
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -117,20 +117,31 @@ void diag_notify_md_client(uint8_t peripheral, int data)
	if (driver->logging_mode != DIAG_MEMORY_DEVICE_MODE)
		return;

	mutex_lock(&driver->diag_file_mutex);
	mutex_lock(&driver->md_session_lock);
	memset(&info, 0, sizeof(struct siginfo));
	info.si_code = SI_QUEUE;
	info.si_int = (PERIPHERAL_MASK(peripheral) | data);
	info.si_signo = SIGCONT;
	if (driver->md_session_map[peripheral] &&
		driver->md_session_map[peripheral]->task) {
		if (driver->md_session_map[peripheral]->pid ==
			driver->md_session_map[peripheral]->task->tgid) {
			DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
				"md_session %d pid = %d, md_session %d task tgid = %d\n",
				peripheral,
				driver->md_session_map[peripheral]->pid,
				peripheral,
				driver->md_session_map[peripheral]->task->tgid);
			stat = send_sig_info(info.si_signo, &info,
				driver->md_session_map[peripheral]->task);
			if (stat)
				pr_err("diag: Err sending signal to memory device client, signal data: 0x%x, stat: %d\n",
					info.si_int, stat);
		} else
			pr_err("diag: md_session_map[%d] data is corrupted, signal data: 0x%x, stat: %d\n",
				peripheral, info.si_int, stat);
	}
	mutex_unlock(&driver->diag_file_mutex);
	mutex_unlock(&driver->md_session_lock);
}

static void process_pd_status(uint8_t *buf, uint32_t len,