From: Wen Xie Date: Tue, 19 Feb 2019 07:45:20 +0000 (+0800) Subject: chub: ipc: fix kernel panic by runtime error X-Git-Tag: MMI-PSB29.39-49-7~252 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=80e5b1696df15abda4853ad6fdbf8d03fd539e9b;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git chub: ipc: fix kernel panic by runtime error Samsung patch: fix kernel panic by runtime error. Change-Id: I4f93bb680c570042e6c3a49b88e549b357edd063 Signed-off-by: Wen Xie Reviewed-on: https://gerrit.mot.com/1310433 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Yuchang Guo Reviewed-by: Hua Tan Submit-Approved: Jira Key --- diff --git a/drivers/staging/nanohub/chub_ipc.c b/drivers/staging/nanohub/chub_ipc.c index 5e687c1cc69a..d0129e992c13 100644 --- a/drivers/staging/nanohub/chub_ipc.c +++ b/drivers/staging/nanohub/chub_ipc.c @@ -958,6 +958,7 @@ void ipc_logbuf_outprint(struct runtimelog_buf *rt_buf, u32 loop) struct ipc_logbuf *logbuf = &ipc_map->logbuf; u32 eq; u32 len; + u32 lenout; retry: eq = logbuf->eq; @@ -982,13 +983,15 @@ retry: CSP_PRINTF_INFO("%s: FW-ERR: %s", NAME_PREFIX, (char *)log); if (rt_buf) { - if (rt_buf->write_index + len + LOGFILE_NUM_SIZE > rt_buf->buffer_size) + if (rt_buf->write_index + len + LOGFILE_NUM_SIZE >= rt_buf->buffer_size) rt_buf->write_index = 0; - len = sprintf(rt_buf->buffer + rt_buf->write_index, "%10d:%s", log->size, log); - rt_buf->write_index += len; + lenout = snprintf(rt_buf->buffer + rt_buf->write_index, LOGFILE_NUM_SIZE + len, "%10d:%s\n", log->size, log); + rt_buf->write_index += lenout; + if (lenout != (LOGFILE_NUM_SIZE + len)) + pr_info("%s: %s: size-n missmatch: %d -> %d\n", NAME_PREFIX, __func__, LOGFILE_NUM_SIZE + len, lenout); } } else { - pr_err("%s: size err:%d, eq:%d, dq:%d\n", __func__, len, eq, logbuf->dq); + pr_err("%s: %s: size err:%d, eq:%d, dq:%d\n", NAME_PREFIX, __func__, len, eq, logbuf->dq); } logbuf->dq = (logbuf->dq + 1) % LOGBUF_NUM; }