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: Abinath S <quic_abins@quicinc.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// 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>
|
||||
@@ -226,6 +227,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];
|
||||
|
||||
@@ -377,6 +377,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];
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2024 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
|
||||
@@ -227,6 +228,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];
|
||||
|
||||
Reference in New Issue
Block a user