diff options
| author | HariKrishna Sagala <hariconscious@gmail.com> | 2025-10-30 16:23:14 +0530 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2025-10-30 14:32:19 +0000 |
| commit | e73b743bfe8a6ff4e05b5657d3f7586a17ac3ba0 (patch) | |
| tree | c8631cc98ce7a201c0835396ff1772b3a50be2f7 /sound/soc/soc-dai.c | |
| parent | 6ef8e042cdcaabe3e3c68592ba8bfbaee2fa10a3 (diff) | |
ASoC: soc-core: check ops & auto_selectable_formats in snd_soc_dai_get_fmt() to prevent dereference error
Smatch reported an issue that "ops" could be null (see
line 174) where later "ops" is dereferenced to extract
the dai fmts, also auto_selectable_formats can also be
null.
Add a proper null check before accessing both the ptrs
to ensure a safe execution.
Signed-off-by: HariKrishna Sagala <hariconscious@gmail.com>
Link: https://patch.msgid.link/20251030105313.32199-2-hariconscious@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-dai.c')
| -rw-r--r-- | sound/soc/soc-dai.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index f231b4174b5f..a1e05307067d 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -177,8 +177,9 @@ u64 snd_soc_dai_get_fmt(const struct snd_soc_dai *dai, int priority) if (max < until) until = max; - for (i = 0; i < until; i++) - fmt |= ops->auto_selectable_formats[i]; + if (ops && ops->auto_selectable_formats) + for (i = 0; i < until; i++) + fmt |= ops->auto_selectable_formats[i]; return fmt; } |
