diag: Fix for possible stale task entries

The task entries were cleared while closing the
md session and hence are stale while notifying the client.
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: Manoj Prabhu B <bmanoj@codeaurora.org>
This commit is contained in:
Manoj Prabhu B 2016-05-11 09:25:56 +05:30 committed by Kyle Yan
parent af4cf780a2
commit 46a83e8592

View file

@ -117,19 +117,31 @@ void diag_notify_md_client(uint8_t peripheral, int data)
if (driver->logging_mode != DIAG_MEMORY_DEVICE_MODE)
return;
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) {
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);
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->md_session_lock);
}
static void process_pd_status(uint8_t *buf, uint32_t len,