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

Commit 293b729b authored by Abinath S's avatar Abinath S Committed by Sumangala P
Browse files

asoc: codec: avoid out of bound write to map array



added check for port num and channel iteration are lessthan 8
to avoid out of bound write to 8x8 map array.

Change-Id: I4c6fe13a5eb09be623a1c40ce16c5a5e4246e021
Signed-off-by: default avatarAbinath S <quic_abins@quicinc.com>
(cherry picked from commit b12699f4)
parent 6c57248b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
 */

#include <linux/module.h>
@@ -223,6 +224,10 @@ static int rouleur_parse_port_mapping(struct device *dev,

	for (i = 0; i < map_length; i++) {
		port_num = dt_array[NUM_SWRS_DT_PARAMS * i];
		if (port_num >= MAX_PORT || ch_iter >= MAX_CH_PER_PORT) {
			dev_err(dev, "%s: Invalid port or channel number\n", __func__);
			goto err_pdata_fail;
		}
		slave_port_type = dt_array[NUM_SWRS_DT_PARAMS * i + 1];
		ch_mask = dt_array[NUM_SWRS_DT_PARAMS * i + 2];
		ch_rate = dt_array[NUM_SWRS_DT_PARAMS * i + 3];
+5 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
 * Copyright (c) 2023,2024 Qualcomm Innovation Center, Inc. All rights reserved.
 */

#include <linux/module.h>
@@ -279,6 +279,10 @@ static int wcd937x_parse_port_mapping(struct device *dev,

	for (i = 0; i < map_length; i++) {
		port_num = dt_array[NUM_SWRS_DT_PARAMS * i];
		if (port_num >= MAX_PORT || ch_iter >= MAX_CH_PER_PORT) {
			dev_err(dev, "%s: Invalid port or channel number\n", __func__);
			goto err_pdata_fail;
		}
		slave_port_type = dt_array[NUM_SWRS_DT_PARAMS * i + 1];
		ch_mask = dt_array[NUM_SWRS_DT_PARAMS * i + 2];
		ch_rate = dt_array[NUM_SWRS_DT_PARAMS * i + 3];
+7 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
 */

#include <linux/module.h>
@@ -377,6 +378,12 @@ static int wcd938x_parse_port_mapping(struct device *dev,

	for (i = 0; i < map_length; i++) {
		port_num = dt_array[NUM_SWRS_DT_PARAMS * i];

		if (port_num >= MAX_PORT || ch_iter >= MAX_CH_PER_PORT) {
			dev_err(dev, "%s: Invalid port or channel number\n", __func__);
			goto err_pdata_fail;
		}

		slave_port_type = dt_array[NUM_SWRS_DT_PARAMS * i + 1];
		ch_mask = dt_array[NUM_SWRS_DT_PARAMS * i + 2];
		ch_rate = dt_array[NUM_SWRS_DT_PARAMS * i + 3];