Browse Source

qcacld-3.0: Properly free ll_stats memory during file release

Since the ll_stats buffer is allocated during debugfs file open
it needs to be freed in file release but, DSC vdev op-protection is
not needed for releasing the buffer. Adding DSC protection will lead
to resource leak because DSC will reject file release op call
if it is in the middle of vdev/psoc/driver transition.

Hence, properly free the ll_stats memory during file release.

Change-Id: Id4c5ee99283a16232b0756341c4422f6f4397667
CRs-Fixed: 2931104
Aditya Kodukula 4 years ago
parent
commit
cd01521734
1 changed files with 13 additions and 44 deletions
  1. 13 44
      core/hdd/src/wlan_hdd_debugfs_llstat.c

+ 13 - 44
core/hdd/src/wlan_hdd_debugfs_llstat.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -502,37 +502,6 @@ static int wlan_hdd_open_ll_stats_debugfs(struct inode *inode,
 	return errno;
 }
 
-/**
- * __wlan_hdd_release_ll_stats_debugfs() - Function to save private on release
- * @net_dev: net_device context used to register the debugfs file
- *
- * Return: Errno
- */
-static int __wlan_hdd_release_ll_stats_debugfs(struct net_device *net_dev)
-{
-	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(net_dev);
-	struct hdd_context *hdd_ctx;
-	int ret;
-
-	hdd_enter();
-
-	if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) {
-		hdd_err("Invalid adapter or adapter has invalid magic");
-		return -EINVAL;
-	}
-
-	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
-	ret = wlan_hdd_validate_context(hdd_ctx);
-	if (ret)
-		return ret;
-
-	wlan_hdd_llstats_free_buf();
-
-	hdd_exit();
-
-	return 0;
-}
-
 /**
  * wlan_hdd_release_ll_stats_debugfs() - SSR wrapper function to save private
  *                                       on release
@@ -544,19 +513,19 @@ static int __wlan_hdd_release_ll_stats_debugfs(struct net_device *net_dev)
 static int wlan_hdd_release_ll_stats_debugfs(struct inode *inode,
 					     struct file *file)
 {
-	struct net_device *net_dev = file_inode(file)->i_private;
-	struct osif_vdev_sync *vdev_sync;
-	int errno;
-
-	errno = osif_vdev_sync_op_start(net_dev, &vdev_sync);
-	if (errno)
-		return errno;
-
-	errno = __wlan_hdd_release_ll_stats_debugfs(net_dev);
-
-	osif_vdev_sync_op_stop(vdev_sync);
+	/* Memory allocated during open_ll_stats_debugfs is static to this file
+	 * and not related to vdev/psoc, and hence it can be freed without DSC
+	 * protection during release file op.
+	 *
+	 * Since ll_stats buffer is allocated during debugfs file open
+	 * it needs to be freed in file release but, DSC vdev op-protection is
+	 * not needed for releasing the ll_stats buffer. Adding DSC protection
+	 * will lead to resource leak because DSC will reject file release
+	 * op call if it is in the middle of vdev/psoc/driver transition.
+	 */
+	wlan_hdd_llstats_free_buf();
 
-	return errno;
+	return 0;
 }
 
 static const struct file_operations fops_ll_stats_debugfs = {