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

This commit is contained in:
QCTECMDR Service 2024-10-30 02:37:19 -07:00 • committed by Gerrit - the friendly Code Review server
commit 5bd7691e3c
3 changed files with 17 additions and 2 deletions

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/module.h>
@ -257,6 +258,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];

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/module.h>
@ -315,6 +315,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];

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022,2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/module.h>
@ -395,6 +395,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];