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

Commit 737269aa authored by Kenneth Westfield's avatar Kenneth Westfield
Browse files

ASoC: msm: qdsp6v2: Check for null pointer



Add check for null pointer after kmalloc in
config_debug_fs_init() and log error message if
true.

CRs-Fixed: 575229
Change-Id: I9824ffa447153581efdf7cb87838538d1e99b0f2
Signed-off-by: default avatarKenneth Westfield <kwestfie@codeaurora.org>
parent 9c6389a6
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -115,6 +115,10 @@ static int audio_output_latency_dbgfs_open(struct inode *inode,
static ssize_t audio_output_latency_dbgfs_read(struct file *file,
				char __user *buf, size_t count, loff_t *ppos)
{
	if (out_buffer == NULL) {
		pr_err("out_buffer is null");
		return 0;
	}
	snprintf(out_buffer, OUT_BUFFER_SIZE, "%ld,%ld,%ld,%ld,%ld,%ld,",\
		out_cold_tv.tv_sec, out_cold_tv.tv_usec, out_warm_tv.tv_sec,\
		out_warm_tv.tv_usec, out_cont_tv.tv_sec, out_cont_tv.tv_usec);
@@ -160,6 +164,10 @@ static int audio_input_latency_dbgfs_open(struct inode *inode,
static ssize_t audio_input_latency_dbgfs_read(struct file *file,
				char __user *buf, size_t count, loff_t *ppos)
{
	if (in_buffer == NULL) {
		pr_err("in_buffer is null");
		return 0;
	}
	snprintf(in_buffer, IN_BUFFER_SIZE, "%ld,%ld,",\
				in_cont_tv.tv_sec, in_cont_tv.tv_usec);
	return  simple_read_from_buffer(buf, IN_BUFFER_SIZE, ppos,
@@ -275,12 +283,16 @@ static void config_debug_fs_write(struct audio_buffer *ab)
static void config_debug_fs_init(void)
{
	out_buffer = kmalloc(OUT_BUFFER_SIZE, GFP_KERNEL);
	if (out_buffer == NULL)
		pr_err("kmalloc() for out_buffer failed");
	out_dentry = debugfs_create_file("audio_out_latency_measurement_node",\
				S_IRUGO | S_IWUSR | S_IWGRP,\
				NULL, NULL, &audio_output_latency_debug_fops);
	if (IS_ERR(out_dentry))
		pr_err("debugfs_create_file failed\n");
	in_buffer = kmalloc(IN_BUFFER_SIZE, GFP_KERNEL);
	if (in_buffer == NULL)
		pr_err("kmalloc() for in_buffer failed");
	in_dentry = debugfs_create_file("audio_in_latency_measurement_node",\
				S_IRUGO | S_IWUSR | S_IWGRP,\
				NULL, NULL, &audio_input_latency_debug_fops);