Unverified Commit e92a309b authored by Mark Brown's avatar Mark Brown
Browse files

Merge series "ASoC: sdm845: array out of bound issues" from Srinivas...

Merge series "ASoC: sdm845: array out of bound issues" from Srinivas Kandagatla <srinivas.kandagatla@linaro.org>:

During testing John Stultz and Amit reported few array our bound issues
after enabling bound sanitizer

This patch series attempts to fix those!

changes since v1:
	- make sure the wcd is not de-referenced without intialization

Srinivas Kandagatla (3):
  ASoC: qcom: sdm845: Fix array out of bounds access
  ASoC: qcom: sdm845: Fix array out of range on rx slim channels
  ASoC: codecs: wcd934x: add a sanity check in set channel map

 sound/soc/codecs/wcd934x.c | 6 ++++++
 sound/soc/qcom/sdm845.c    | 6 +++---
 2 files changed, 9 insertions(+), 3 deletions(-)

--
2.21.0
parents fd829918 3bb4852d
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -1873,6 +1873,12 @@ static int wcd934x_set_channel_map(struct snd_soc_dai *dai,


	wcd = snd_soc_component_get_drvdata(dai->component);
	wcd = snd_soc_component_get_drvdata(dai->component);


	if (tx_num > WCD934X_TX_MAX || rx_num > WCD934X_RX_MAX) {
		dev_err(wcd->dev, "Invalid tx %d or rx %d channel count\n",
			tx_num, rx_num);
		return -EINVAL;
	}

	if (!tx_slot || !rx_slot) {
	if (!tx_slot || !rx_slot) {
		dev_err(wcd->dev, "Invalid tx_slot=%p, rx_slot=%p\n",
		dev_err(wcd->dev, "Invalid tx_slot=%p, rx_slot=%p\n",
			tx_slot, rx_slot);
			tx_slot, rx_slot);
+3 −3
Original line number Original line Diff line number Diff line
@@ -27,18 +27,18 @@
#define SPK_TDM_RX_MASK         0x03
#define SPK_TDM_RX_MASK         0x03
#define NUM_TDM_SLOTS           8
#define NUM_TDM_SLOTS           8
#define SLIM_MAX_TX_PORTS 16
#define SLIM_MAX_TX_PORTS 16
#define SLIM_MAX_RX_PORTS 16
#define SLIM_MAX_RX_PORTS 13
#define WCD934X_DEFAULT_MCLK_RATE	9600000
#define WCD934X_DEFAULT_MCLK_RATE	9600000


struct sdm845_snd_data {
struct sdm845_snd_data {
	struct snd_soc_jack jack;
	struct snd_soc_jack jack;
	bool jack_setup;
	bool jack_setup;
	bool stream_prepared[SLIM_MAX_RX_PORTS];
	bool stream_prepared[AFE_PORT_MAX];
	struct snd_soc_card *card;
	struct snd_soc_card *card;
	uint32_t pri_mi2s_clk_count;
	uint32_t pri_mi2s_clk_count;
	uint32_t sec_mi2s_clk_count;
	uint32_t sec_mi2s_clk_count;
	uint32_t quat_tdm_clk_count;
	uint32_t quat_tdm_clk_count;
	struct sdw_stream_runtime *sruntime[SLIM_MAX_RX_PORTS];
	struct sdw_stream_runtime *sruntime[AFE_PORT_MAX];
};
};


static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};