* [linux-next:master 5407/6912] sound/soc/sof/sof-audio.c:329 sof_prepare_widgets_in_path() error: we previously assumed 'swidget' could be null (see line 306)
@ 2023-01-20 9:57 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2023-01-20 9:57 UTC (permalink / raw)
To: oe-kbuild, Ranjani Sridharan
Cc: lkp, oe-kbuild-all, Linux Memory Management List, Mark Brown,
Peter Ujfalusi, Rander Wang, AngeloGioacchino Del Regno
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: d514392f17fd4d386cfadde7f849d97db4ca1fb0
commit: 0ad84b11f2f8dd19d62d0b2ffd95ece897e6c3dc [5407/6912] ASoC: SOF: sof-audio: skip prepare/unprepare if swidget is NULL
config: csky-randconfig-m041-20230119 (https://download.01.org/0day-ci/archive/20230120/202301201736.O3WvrMfz-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 12.1.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
smatch warnings:
sound/soc/sof/sof-audio.c:329 sof_prepare_widgets_in_path() error: we previously assumed 'swidget' could be null (see line 306)
vim +/swidget +329 sound/soc/sof/sof-audio.c
66344c6d92113e Ranjani Sridharan 2022-04-26 294 static int
66344c6d92113e Ranjani Sridharan 2022-04-26 295 sof_prepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *widget,
66344c6d92113e Ranjani Sridharan 2022-04-26 296 struct snd_pcm_hw_params *fe_params,
66344c6d92113e Ranjani Sridharan 2022-04-26 297 struct snd_sof_platform_stream_params *platform_params,
66344c6d92113e Ranjani Sridharan 2022-04-26 298 struct snd_pcm_hw_params *pipeline_params, int dir)
66344c6d92113e Ranjani Sridharan 2022-04-26 299 {
66344c6d92113e Ranjani Sridharan 2022-04-26 300 const struct sof_ipc_tplg_ops *ipc_tplg_ops = sdev->ipc->ops->tplg;
66344c6d92113e Ranjani Sridharan 2022-04-26 301 const struct sof_ipc_tplg_widget_ops *widget_ops = ipc_tplg_ops->widget;
66344c6d92113e Ranjani Sridharan 2022-04-26 302 struct snd_sof_widget *swidget = widget->dobj.private;
66344c6d92113e Ranjani Sridharan 2022-04-26 303 struct snd_soc_dapm_path *p;
66344c6d92113e Ranjani Sridharan 2022-04-26 304 int ret;
66344c6d92113e Ranjani Sridharan 2022-04-26 305
0ad84b11f2f8dd Ranjani Sridharan 2023-01-18 @306 if (!swidget || !widget_ops[widget->id].ipc_prepare || swidget->prepared)
^^^^^^^
Check for NULL
66344c6d92113e Ranjani Sridharan 2022-04-26 307 goto sink_prepare;
66344c6d92113e Ranjani Sridharan 2022-04-26 308
66344c6d92113e Ranjani Sridharan 2022-04-26 309 /* prepare the source widget */
66344c6d92113e Ranjani Sridharan 2022-04-26 310 ret = widget_ops[widget->id].ipc_prepare(swidget, fe_params, platform_params,
66344c6d92113e Ranjani Sridharan 2022-04-26 311 pipeline_params, dir);
66344c6d92113e Ranjani Sridharan 2022-04-26 312 if (ret < 0) {
66344c6d92113e Ranjani Sridharan 2022-04-26 313 dev_err(sdev->dev, "failed to prepare widget %s\n", widget->name);
66344c6d92113e Ranjani Sridharan 2022-04-26 314 return ret;
66344c6d92113e Ranjani Sridharan 2022-04-26 315 }
66344c6d92113e Ranjani Sridharan 2022-04-26 316
66344c6d92113e Ranjani Sridharan 2022-04-26 317 swidget->prepared = true;
66344c6d92113e Ranjani Sridharan 2022-04-26 318
66344c6d92113e Ranjani Sridharan 2022-04-26 319 sink_prepare:
66344c6d92113e Ranjani Sridharan 2022-04-26 320 /* prepare all widgets in the sink paths */
66344c6d92113e Ranjani Sridharan 2022-04-26 321 snd_soc_dapm_widget_for_each_sink_path(widget, p) {
66344c6d92113e Ranjani Sridharan 2022-04-26 322 if (!p->walking && p->sink->dobj.private) {
66344c6d92113e Ranjani Sridharan 2022-04-26 323 p->walking = true;
66344c6d92113e Ranjani Sridharan 2022-04-26 324 ret = sof_prepare_widgets_in_path(sdev, p->sink, fe_params,
66344c6d92113e Ranjani Sridharan 2022-04-26 325 platform_params, pipeline_params, dir);
66344c6d92113e Ranjani Sridharan 2022-04-26 326 p->walking = false;
66344c6d92113e Ranjani Sridharan 2022-04-26 327 if (ret < 0) {
66344c6d92113e Ranjani Sridharan 2022-04-26 328 /* unprepare the source widget */
2fe08216fda33b Amadeusz Sławiński 2022-06-02 @329 if (widget_ops[widget->id].ipc_unprepare && swidget->prepared) {
^^^^^^^^^^^^^^^^^
Unchecked dereference
66344c6d92113e Ranjani Sridharan 2022-04-26 330 widget_ops[widget->id].ipc_unprepare(swidget);
66344c6d92113e Ranjani Sridharan 2022-04-26 331 swidget->prepared = false;
66344c6d92113e Ranjani Sridharan 2022-04-26 332 }
66344c6d92113e Ranjani Sridharan 2022-04-26 333 return ret;
66344c6d92113e Ranjani Sridharan 2022-04-26 334 }
66344c6d92113e Ranjani Sridharan 2022-04-26 335 }
66344c6d92113e Ranjani Sridharan 2022-04-26 336 }
66344c6d92113e Ranjani Sridharan 2022-04-26 337
66344c6d92113e Ranjani Sridharan 2022-04-26 338 return 0;
66344c6d92113e Ranjani Sridharan 2022-04-26 339 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-20 9:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-20 9:57 [linux-next:master 5407/6912] sound/soc/sof/sof-audio.c:329 sof_prepare_widgets_in_path() error: we previously assumed 'swidget' could be null (see line 306) Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).