OSDN Git Service

ASoC: SOF: Intel: hda-dai: add error checks to prevent static analysis warnings
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Fri, 2 Jun 2023 20:56:12 +0000 (15:56 -0500)
committerMark Brown <broonie@kernel.org>
Mon, 5 Jun 2023 13:00:52 +0000 (14:00 +0100)
commitc4be6024d51d3930459a61d4c91990f20264c60b
treee78c6bea6cc3c5bdc4bfef9ee6dcf78045c5088d
parent4ff52a694e249d6a0bf3301bd8e83330bee9608f
ASoC: SOF: Intel: hda-dai: add error checks to prevent static analysis warnings

make KCFLAGS='-fanalyzer' sound/soc/sof/intel/ reports several NULL
pointer dereference paths.

Example log:
ops = hda_dai_get_ops(substream, cpu_dai);
  |      |                          ^~~~~
  |      |                          |
  |      |               (14) return of NULL to ‘non_hda_dai_hw_params’ from ‘hda_dai_get_ops’
  |  353 |         sdev = widget_to_sdev(w);
  |  354 |         hext_stream = ops->get_hext_stream(sdev, cpu_dai, substream);
  |      |                       ~~~~~~~~~~~~~~~~~~~~
  |      |                          |
  |      |                          (15) dereference of NULL ‘ops’

The function hda_dai_get_ops() can return NULL, but the return value
is not checked across the board. It's not a problem today, since we do
check in the first use of the function, but static analysis tools are
not aware of the different ALSA stages. Rather than argue forever,
let's just add the error checks consistently and make sure this tool
can be added to the CI checks.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20230602205620.310879-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/hda-dai.c