]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: soc-core: check ops & auto_selectable_formats in snd_soc_dai_get_fmt() to preve...
authorHariKrishna Sagala <hariconscious@gmail.com>
Thu, 30 Oct 2025 10:53:14 +0000 (16:23 +0530)
committerMark Brown <broonie@kernel.org>
Thu, 30 Oct 2025 14:32:19 +0000 (14:32 +0000)
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>
sound/soc/soc-dai.c

index f231b4174b5fcbfd9b723e7a9d3fee237f3c5b68..a1e05307067d986a0c79f151f6ebb545e73314d7 100644 (file)
@@ -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;
 }