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

Commit 9fb522a5 authored by Mohammed Nayeem Ur Rahman's avatar Mohammed Nayeem Ur Rahman Committed by Gerrit - the friendly Code Review server
Browse files

msm: adsprpc: Fix NULL pointer error when DEBUG_FS is disabled



Add extra checks to avoid NULL pointer derefernce when DEBUG_FS
is disabled.

Change-Id: I46ff3b8b27b53ff5bb5dead78ccdefc410435dda
Acked-by: default avatarTadakamalla Krishnaiah <ktadakam@qti.qualcomm.com>
Signed-off-by: default avatarMohammed Nayeem Ur Rahman <mohara@codeaurora.org>
parent 2a7519b1
Loading
Loading
Loading
Loading
+35 −15
Original line number Diff line number Diff line
@@ -4898,7 +4898,9 @@ static int fastrpc_set_process_info(struct fastrpc_file *fl)

	fl->tgid = current->tgid;
	snprintf(strpid, PID_SIZE, "%d", current->pid);
	buf_size = strlen(current->comm) + strlen("_") + strlen(strpid) + 1;
	if (debugfs_root) {
		buf_size = strlen(current->comm) + strlen("_")
			+ strlen(strpid) + 1;
		fl->debug_buf = kzalloc(buf_size, GFP_KERNEL);
		if (!fl->debug_buf) {
			err = -ENOMEM;
@@ -4908,9 +4910,14 @@ static int fastrpc_set_process_info(struct fastrpc_file *fl)
			current->comm, "_", current->pid);
		fl->debugfs_file = debugfs_create_file(fl->debug_buf, 0644,
			debugfs_root, fl, &debugfs_fops);
	if (!fl->debugfs_file)
		ADSPRPC_WARN("failed to create debugfs file %s\n",
				fl->debug_buf);
		if (IS_ERR_OR_NULL(fl->debugfs_file)) {
			pr_warn("Error: %s: %s: failed to create debugfs file %s\n",
				current->comm, __func__, fl->debug_buf);
			fl->debugfs_file = NULL;
			kfree(fl->debug_buf);
			fl->debug_buf = NULL;
		}
	}
	return err;
}

@@ -5700,6 +5707,15 @@ static int fastrpc_cb_probe(struct device *dev)
	}

	chan->sesscount++;
	if (debugfs_root) {
		debugfs_global_file = debugfs_create_file("global", 0644,
			debugfs_root, NULL, &debugfs_fops);
		if (IS_ERR_OR_NULL(debugfs_global_file)) {
			pr_warn("Error: %s: %s: failed to create debugfs global file\n",
				current->comm, __func__);
			debugfs_global_file = NULL;
		}
	}
bail:
	return err;
}
@@ -5948,8 +5964,12 @@ static int __init fastrpc_device_init(void)
	int err = 0, i;

	debugfs_root = debugfs_create_dir("adsprpc", NULL);
	debugfs_global_file = debugfs_create_file("global", 0644, debugfs_root,
							NULL, &debugfs_fops);
	if (IS_ERR_OR_NULL(debugfs_root)) {
		pr_warn("Error: %s: %s: failed to create debugfs root dir\n",
			current->comm, __func__);
		debugfs_remove_recursive(debugfs_root);
		debugfs_root = NULL;
	}
	memset(me, 0, sizeof(*me));
	fastrpc_init(me);
	me->dev = NULL;