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

Commit 4a12f258 authored by Sandhya Mutha Naga Venkata's avatar Sandhya Mutha Naga Venkata Committed by Gerrit - the friendly Code Review server
Browse files

dsp: q6voice: Add buf size check for cvs cal data



Check for the max size of cvs command register
calibration data that can be copied else will
result in buffer overflow.

Change-Id: Id7a4c5a9795143798b68dfde779f17fb450e3848
Signed-off-by: default avatarSoumya Managoli <quic_c_smanag@quicinc.com>
parent fd6f1d2a
Loading
Loading
Loading
Loading
+10 −10
Original line number Original line Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 *
 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
 */
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/kthread.h>
#include <linux/kthread.h>
@@ -2642,6 +2635,13 @@ static int voice_send_cvs_register_cal_cmd(struct voice_data *v)
		goto unlock;
		goto unlock;
	}
	}


	if (col_data->cal_data.size >= MAX_COL_INFO_SIZE) {
		pr_err("%s: Invalid cal data size %d!\n",
			__func__, col_data->cal_data.size);
		ret = -EINVAL;
		goto unlock;
	}

	memcpy(&cvs_reg_cal_cmd.cvs_cal_data.column_info[0],
	memcpy(&cvs_reg_cal_cmd.cvs_cal_data.column_info[0],
	       (void *) &((struct audio_cal_info_voc_col *)
	       (void *) &((struct audio_cal_info_voc_col *)
	       col_data->cal_info)->data,
	       col_data->cal_info)->data,