ASoC: mediatek: mt8186: remove unnecessary judgments
Subsystems (3)
PATCH 1/1 ASoC: mediatek: mt8186: remove unnecessary judgments
The afe_priv->dai_priv[] is allocated when platform driver probe(), if it failed, the ASoC platform driver probe() will return fail first. Therefore, this is excessive judgment, and the condition will never be established.
Bug report: https://www.spinics.net/lists/alsa-devel/msg145609.html
This is a semi-automatic email about new static checker warnings.
The patch ae92dcbee8b6: "ASoC: mediatek: mt8186: support tdm in platform driver" from May 23, 2022, leads to the following Smatch complaint:
sound/soc/mediatek/mt8186/mt8186-dai-tdm.c:424 mtk_dai_tdm_hw_params()
warn: variable dereferenced before check 'tdm_priv' (see line 406)
sound/soc/mediatek/mt8186/mt8186-dai-tdm.c
405 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[tdm_id];
406 unsigned int tdm_mode = tdm_priv->tdm_mode;
^^^^^^^^^^^^^^^^^^^Lot's of dereferences
407 unsigned int data_mode = tdm_priv->data_mode;
408 unsigned int rate = params_rate(params);
409 unsigned int channels = params_channels(params);
410 snd_pcm_format_t format = params_format(params);
411 unsigned int bit_width =
412 snd_pcm_format_physical_width(format);
413 unsigned int tdm_channels = (data_mode == TDM_DATA_ONE_PIN) ?
414 get_tdm_ch_per_sdata(tdm_mode, channels) : 2;
415 unsigned int lrck_width =
416 get_tdm_lrck_width(format, tdm_mode);
417 unsigned int tdm_con = 0;
418 bool slave_mode = tdm_priv->slave_mode;
419 bool lrck_inv = tdm_priv->lck_invert;
420 bool bck_inv = tdm_priv->bck_invert;
421 unsigned int tran_rate;
422 unsigned int tran_relatch_rate;
423
424 if (!tdm_priv) {
^^^^^^^^^Checked too late
425 dev_err(afe->dev, "%s(), tdm_priv == NULL", __func__); 426 return -EINVAL;
--- sound/soc/mediatek/mt8186/mt8186-dai-adda.c | 5 -- sound/soc/mediatek/mt8186/mt8186-dai-i2s.c | 63 --------------------- sound/soc/mediatek/mt8186/mt8186-dai-pcm.c | 5 -- sound/soc/mediatek/mt8186/mt8186-dai-tdm.c | 55 +----------------- 4 files changed, 1 insertion(+), 127 deletions(-)
sound/soc/mediatek/mt8186/mt8186-dai-adda.c +0 -5
@@ -655,11 +655,6 @@ static int mtk_dai_adda_hw_params(struct snd_pcm_substream *substream,dev_dbg (afe->dev,"%s(), id %d, stream %d, rate %d\n" , __func__, id, substream->stream, rate); -if (!adda_priv) { -dev_err (afe->dev,"%s(), adda_priv == NULL" , __func__); -return -EINVAL ; - } -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) {unsigned int dl_src2_con0;unsigned int dl_src2_con1;
sound/soc/mediatek/mt8186/mt8186-dai-i2s.c +0 -63
131 lines not on this page · raw message
sound/soc/mediatek/mt8186/mt8186-dai-pcm.c +0 -5
@@ -287,11 +287,6 @@ static int mtk_dai_pcm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)struct mt8186_afe_private *afe_priv = afe->platform_priv;struct mtk_afe_pcm_priv *pcm_priv = afe_priv->dai_priv[dai->id]; -if (!pcm_priv) { -dev_err (afe->dev,"%s(), tdm_priv == NULL" , __func__); -return -EINVAL ; - } -/* DAI mode*/ switch (fmt &SND_SOC_DAIFMT_FORMAT_MASK ) {case SND_SOC_DAIFMT_I2S :
sound/soc/mediatek/mt8186/mt8186-dai-tdm.c +1 -54
122 lines not on this page · raw message
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 8 lines · Jiaxin Yu
The afe_priv->dai_priv[] is allocated when platform driver
probe(), if it failed, the ASoC platform driverprobe()will return fail first. Therefore, this is excessive judgment, and the condition will never be established.Bug report: https://www.spinics.net/lists/alsa-devel/msg145609.html
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: mediatek: mt8186: remove unnecessary judgments
commit: d7bffbe9cbd3c96fe51a8482127cabf6fa1fd9b2
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark