From 3c2b633bb91e0f270e583af6d4ee6dffa12d298d Mon Sep 17 00:00:00 2001 From: Tharun Kumar Merugu Date: Wed, 22 Mar 2017 16:28:40 +0530 Subject: [PATCH] sdm660: ADSPRPC: Null check file session ctx during mmap create During fastrpc mmap create and mmap free, we are dereferencing file session context without checking for Null. Change-Id: I65fc2bb566e2e6e7914b86044e17577a96db6b4f Acked-by: Vishnu Karthik D Signed-off-by: Tharun Kumar Merugu --- drivers/char/adsprpc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c index e0106a7e31fa..8261af23d03e 100644 --- a/drivers/char/adsprpc.c +++ b/drivers/char/adsprpc.c @@ -553,7 +553,7 @@ static void fastrpc_mmap_free(struct fastrpc_mmap *map) if (!IS_ERR_OR_NULL(map->handle)) ion_free(fl->apps->client, map->handle); - if (sess->smmu.enabled) { + if (sess && sess->smmu.enabled) { if (map->size || map->phys) msm_dma_unmap_sg(sess->smmu.dev, map->table->sgl, @@ -645,6 +645,9 @@ static int fastrpc_mmap_create(struct fastrpc_file *fl, int fd, unsigned attr, else sess = fl->sctx; + VERIFY(err, !IS_ERR_OR_NULL(sess)); + if (err) + goto bail; VERIFY(err, !IS_ERR_OR_NULL(map->buf = dma_buf_get(fd))); if (err) goto bail;