Prechádzať zdrojové kódy

cnss2: free host ramdump device properly

As per description of device_add(), never directly free
a device after calling device_add(), should always
use put_device() to give up the reference and free it
in callback function 'release' if it's required.

Change-Id: I5b07b49bcf2e2af6994c05ef038deebc92a825b7
CRs-Fixed: 3637349
Yu Wang 1 rok pred
rodič
commit
da6fe13a18
1 zmenil súbory, kde vykonal 14 pridanie a 1 odobranie
  1. 14 1
      cnss2/main.c

+ 14 - 1
cnss2/main.c

@@ -3237,6 +3237,18 @@ skip_elf_dump:
 }
 
 #ifdef CONFIG_CNSS2_SSR_DRIVER_DUMP
+/**
+ * cnss_host_ramdump_dev_release() - callback function for device release
+ * @dev: device to be released
+ *
+ * Return: None
+ */
+static void cnss_host_ramdump_dev_release(struct device *dev)
+{
+	cnss_pr_dbg("free host ramdump device\n");
+	kfree(dev);
+}
+
 int cnss_do_host_ramdump(struct cnss_plat_data *plat_priv,
 			 struct cnss_ssr_driver_dump_entry *ssr_entry,
 			 size_t num_entries_loaded)
@@ -3377,6 +3389,7 @@ int cnss_do_host_ramdump(struct cnss_plat_data *plat_priv,
 		return -ENOMEM;
 	}
 
+	new_device->release = cnss_host_ramdump_dev_release;
 	device_initialize(new_device);
 	dev_set_name(new_device, "wlan_driver");
 	dev_ret = device_add(new_device);
@@ -3444,7 +3457,7 @@ skip_host_dump:
 	device_del(new_device);
 put_device:
 	put_device(new_device);
-	kfree(new_device);
+	cnss_pr_dbg("host ramdump result %d\n", ret);
 	return ret;
 }
 #endif