Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 340cfc6a authored by Liangliang Lu's avatar Liangliang Lu
Browse files

usb: gadget: f_fs: Do not free IPC log buffer when free instance



Currently we allocate IPC log buffer when instance is created,
and free IPC log buffer when instance is freed.

So we can't get IPC log when issue happens after the instance
is freed.

Move IPC log buffer allocate and free to module init and exit.

Change-Id: Ic8b0f6d91c9bbbf2a6a6ed87f96c04475a09b7f3
Signed-off-by: default avatarLiangliang Lu <luliang@codeaurora.org>
parent 1cbd1cdf
Loading
Loading
Loading
Loading
+25 −11
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@

static void *ffs_ipc_log;
#define ffs_log(fmt, ...) do { \
	if (ffs_ipc_log)	\
		ipc_log_string(ffs_ipc_log, "%s: " fmt,  __func__, \
			##__VA_ARGS__); \
	pr_debug(fmt, ##__VA_ARGS__); \
@@ -1610,10 +1611,6 @@ static int functionfs_init(void)
	else
		pr_err("failed registering file system (%d)\n", ret);

	ffs_ipc_log = ipc_log_context_create(NUM_PAGES, "f_fs", 0);
	if (IS_ERR_OR_NULL(ffs_ipc_log))
		ffs_ipc_log =  NULL;

	return ret;
}

@@ -1623,13 +1620,7 @@ static void functionfs_cleanup(void)

	pr_info("unloading\n");
	unregister_filesystem(&ffs_fs_type);

	if (ffs_ipc_log) {
		ipc_log_context_destroy(ffs_ipc_log);
		ffs_ipc_log = NULL;
}
}


/* ffs_data and ffs_function construction and destruction code **************/

@@ -4063,5 +4054,28 @@ static char *ffs_prepare_buffer(const char __user *buf, size_t len)
}

DECLARE_USB_FUNCTION_INIT(ffs, ffs_alloc_inst, ffs_alloc);

static int ffs_init(void)
{
	ffs_ipc_log = ipc_log_context_create(NUM_PAGES, "f_fs", 0);
	if (IS_ERR_OR_NULL(ffs_ipc_log)) {
		ffs_ipc_log =  NULL;
		pr_err("%s: Create IPC log context failure\n",
				__func__);
	}

	return 0;
}
module_init(ffs_init);

static void __exit ffs_exit(void)
{
	if (ffs_ipc_log) {
		ipc_log_context_destroy(ffs_ipc_log);
		ffs_ipc_log = NULL;
	}
}
module_exit(ffs_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Michal Nazarewicz");