summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManoj Prabhu B <bmanoj@codeaurora.org>2016-05-11 09:25:56 +0530
committerKyle Yan <kyan@codeaurora.org>2016-05-24 11:57:03 -0700
commit46a83e85920aa49c437c689154ee136eea91de1c (patch)
tree66a12f7b14b8824c2f8437a28bac5e26f485c2ab
parentaf4cf780a234f39ab3e6a1f14bb404b909e1275f (diff)
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>
-rw-r--r--drivers/char/diag/diagfwd_cntl.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/drivers/char/diag/diagfwd_cntl.c b/drivers/char/diag/diagfwd_cntl.c
index 5d2381069df1..e9d025455382 100644
--- a/drivers/char/diag/diagfwd_cntl.c
+++ b/drivers/char/diag/diagfwd_cntl.c
@@ -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,