linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	Linux Memory Management List <linux-mm@kvack.org>,
	Mark Brown <broonie@kernel.org>,
	Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
	Rander Wang <rander.wang@intel.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>
Subject: [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)
Date: Fri, 20 Jan 2023 12:57:44 +0300	[thread overview]
Message-ID: <202301201736.O3WvrMfz-lkp@intel.com> (raw)

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



                 reply	other threads:[~2023-01-20  9:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202301201736.O3WvrMfz-lkp@intel.com \
    --to=error27@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=broonie@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=rander.wang@intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).