From 7dd7c6a789ce48ccb8a12779406819ca3a88ece1 Mon Sep 17 00:00:00 2001 From: Edgar Flores Date: Tue, 28 Jul 2020 14:06:42 -0700 Subject: [PATCH] msm: ADSPRPC: Map and FD non-NULL check before dereferencing When fd is zero, we set context fds to NULL. This will avoid calling map create for context. Proper check is required to avoid dereferencing of map and fd. Change-Id: Id8d4b93d7d999e14ac1ebd8291137f799a73cf1a Acked-by: Ekansh Gupta Signed-off-by: Jeya R Signed-off-by: Edgar Flores --- drivers/char/adsprpc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c index 2c7c32e4ec8d..f839822fb1a9 100644 --- a/drivers/char/adsprpc.c +++ b/drivers/char/adsprpc.c @@ -2210,9 +2210,10 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx) PERF_END); for (i = bufs; i < bufs + handles; ++i) { struct fastrpc_mmap *map = ctx->maps[i]; - - pages[i].addr = map->phys; - pages[i].size = map->size; + if (map) { + pages[i].addr = map->phys; + pages[i].size = map->size; + } } fdlist = (uint64_t *)&pages[bufs + handles]; crclist = (uint32_t *)&fdlist[M_FDLIST];