From 75ae7139bdab4982b26c3d6f8be0e04ea77068c3 Mon Sep 17 00:00:00 2001 From: Mukesh Ojha Date: Wed, 30 Sep 2020 12:41:21 +0530 Subject: [PATCH] soc: qcom: ramdump: Fix the missed unmap of mapped memory Before copying dump to userspace, memory is mapped and then the content get copied to userspace and later that memory should be unmapped. Let's unmap the memory after the content get copied to userspace. Change-Id: I03d53ebd1cdb743e1820f226a49d46136eca4874 Signed-off-by: Mukesh Ojha --- drivers/soc/qcom/ramdump.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/soc/qcom/ramdump.c b/drivers/soc/qcom/ramdump.c index 7aeb2913a2e2..85b6ae969a1e 100644 --- a/drivers/soc/qcom/ramdump.c +++ b/drivers/soc/qcom/ramdump.c @@ -262,6 +262,8 @@ static ssize_t ramdump_read(struct file *filep, char __user *buf, size_t count, } kfree(finalbuf); + if (!vaddr && origdevice_mem) + iounmap(origdevice_mem); *pos += copy_size; @@ -275,6 +277,8 @@ static ssize_t ramdump_read(struct file *filep, char __user *buf, size_t count, ramdump_done: srcu_read_unlock(&rd_dev->rd_srcu, srcu_idx); kfree(finalbuf); + if (!vaddr && origdevice_mem) + iounmap(origdevice_mem); *pos = 0; reset_ramdump_entry(entry); return ret;