From fdb0189a4acccb012bf604ee811e790b1c2f520b Mon Sep 17 00:00:00 2001 From: Rajeev Kumar Date: Wed, 14 Mar 2018 15:03:19 -0700 Subject: [PATCH] qcacld-3.0: Add SSR protection wrapper for memdump read Memdump read API is missing SSR protection wrapper which means this ready operation can be issued durign driver unload which can race against memdump deinit and lead to panic in kernel. Hence add SSR protection wrapper to memdump read API such that it does not race against driver unload/SSR/module stop. Change-Id: I32d5ab715c9609abaf8eaaf3ed3db6f77aa8ddea CRs-Fixed: 2205925 --- core/hdd/src/wlan_hdd_memdump.c | 35 +++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/core/hdd/src/wlan_hdd_memdump.c b/core/hdd/src/wlan_hdd_memdump.c index 46f426c46404..01da48970930 100644 --- a/core/hdd/src/wlan_hdd_memdump.c +++ b/core/hdd/src/wlan_hdd_memdump.c @@ -94,7 +94,7 @@ static void hdd_driver_mem_cleanup(void) /** - * hdd_driver_memdump_read() - perform read operation in driver + * __hdd_driver_memdump_read() - perform read operation in driver * memory dump proc file * @file - handle for the proc file. * @buf - pointer to user space buffer. @@ -103,10 +103,12 @@ static void hdd_driver_mem_cleanup(void) * * This function performs read operation for the driver memory dump proc file. * - * Return: number of bytes read on success, error code otherwise. + * Return: number of bytes read on success + * negative error code in case of failure + * 0 in case of no more data */ -static ssize_t hdd_driver_memdump_read(struct file *file, char __user *buf, - size_t count, loff_t *pos) +static ssize_t __hdd_driver_memdump_read(struct file *file, char __user *buf, + size_t count, loff_t *pos) { int status; QDF_STATUS qdf_status; @@ -184,6 +186,31 @@ static ssize_t hdd_driver_memdump_read(struct file *file, char __user *buf, return no_of_bytes_read; } +/** + * hdd_driver_memdump_read() - perform read operation in driver + * memory dump proc file + * @file - handle for the proc file. + * @buf - pointer to user space buffer. + * @count - number of bytes to be read. + * @pos - offset in the from buffer. + * + * This function performs read operation for the driver memory dump proc file. + * + * Return: number of bytes read on success + * negative error code in case of failure + * 0 in case of no more data + */ +static ssize_t hdd_driver_memdump_read(struct file *file, char __user *buf, + size_t count, loff_t *pos) +{ + ssize_t len; + + cds_ssr_protect(__func__); + len = __hdd_driver_memdump_read(file, buf, count, pos); + cds_ssr_unprotect(__func__); + + return len; +} /** * struct driver_dump_fops - file operations for driver dump feature