mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
ASoC: qcom: common: validate cpu dai id during parsing
lpass ports numbers have been added but the afe/apm driver never got updated with new max port value that it uses to store dai specific data. There are more than one places these values are cached and always become out of sync. This will result in array out of bounds and weird driver behaviour. To catch such issues, first add a single place where we can define max port and second add a check in common parsing code which can error out before corrupting the memory with out of bounds array access. This should help both avoid and catch these type of mistakes in future. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com> Link: https://patch.msgid.link/20260402081118.348071-8-srinivas.kandagatla@oss.qualcomm.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
e46957f27c
commit
d49ee8faef
|
|
@ -120,6 +120,12 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
|
|||
|
||||
link->id = args.args[0];
|
||||
|
||||
if (link->id >= LPASS_MAX_PORT) {
|
||||
dev_err(dev, "%s: Invalid cpu dai id %d\n", link->name, link->id);
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (platform) {
|
||||
link->platforms->of_node = of_parse_phandle(platform,
|
||||
"sound-dai",
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@
|
|||
#ifndef __QCOM_SND_COMMON_H__
|
||||
#define __QCOM_SND_COMMON_H__
|
||||
|
||||
#include <dt-bindings/sound/qcom,q6afe.h>
|
||||
#include <sound/soc.h>
|
||||
|
||||
#define LPASS_MAX_PORT (SENARY_MI2S_TX + 1)
|
||||
|
||||
int qcom_snd_parse_of(struct snd_soc_card *card);
|
||||
int qcom_snd_wcd_jack_setup(struct snd_soc_pcm_runtime *rtd,
|
||||
struct snd_soc_jack *jack, bool *jack_setup);
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@
|
|||
#include <linux/regmap.h>
|
||||
#include <dt-bindings/sound/qcom,lpass.h>
|
||||
#include <dt-bindings/sound/qcom,q6afe.h>
|
||||
#include "common.h"
|
||||
#include "lpass-hdmi.h"
|
||||
|
||||
#define LPASS_AHBIX_CLOCK_FREQUENCY 131072000
|
||||
#define LPASS_MAX_PORTS (DISPLAY_PORT_RX_7 + 1)
|
||||
#define LPASS_MAX_PORTS (LPASS_MAX_PORT)
|
||||
#define LPASS_MAX_MI2S_PORTS (8)
|
||||
#define LPASS_MAX_DMA_CHANNELS (8)
|
||||
#define LPASS_MAX_HDMI_DMA_CHANNELS (4)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
#ifndef __Q6AFE_H__
|
||||
#define __Q6AFE_H__
|
||||
#include "../common.h"
|
||||
|
||||
#define AFE_PORT_MAX 137
|
||||
#define AFE_PORT_MAX (LPASS_MAX_PORT)
|
||||
|
||||
#define MSM_AFE_PORT_TYPE_RX 0
|
||||
#define MSM_AFE_PORT_TYPE_TX 1
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@
|
|||
#include <linux/of_platform.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/soc/qcom/apr.h>
|
||||
#include "../common.h"
|
||||
#include "audioreach.h"
|
||||
|
||||
#define APM_PORT_MAX 127
|
||||
#define APM_PORT_MAX LPASS_MAX_PORT
|
||||
#define APM_PORT_MAX_AUDIO_CHAN_CNT 8
|
||||
#define PCM_CHANNEL_NULL 0
|
||||
#define PCM_CHANNEL_FL 1 /* Front left channel. */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user