Browse Source

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
Rajeev Kumar 7 years ago
parent
commit
fdb0189a4a
1 changed files with 31 additions and 4 deletions
  1. 31 4
      core/hdd/src/wlan_hdd_memdump.c

+ 31 - 4
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