All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
To: Dan Carpenter <error27@gmail.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: [bug report] ASoC: SOF: ipc4-control: Add support for bytes control get and put
Date: Tue, 21 Mar 2023 15:36:47 +0200	[thread overview]
Message-ID: <6be945d2-40cb-46fb-67ba-ed3a19cddfa4@linux.intel.com> (raw)
In-Reply-To: <4c3570c3-67fe-4b58-baaf-455f69bdfc6b@kili.mountain>

Hi Dan,

On 21/03/2023 09:21, Dan Carpenter wrote:
> Hello Peter Ujfalusi,
> 
> The patch a062c8899fed: "ASoC: SOF: ipc4-control: Add support for
> bytes control get and put" from Mar 13, 2023, leads to the following
> Smatch static checker warning:
> 
> 	sound/soc/sof/ipc4-control.c:436 sof_ipc4_widget_kcontrol_setup()
> 	warn: iterator used outside loop: 'scontrol'
> 
> sound/soc/sof/ipc4-control.c
>     411 static int sof_ipc4_widget_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
>     412 {
>     413         struct snd_sof_control *scontrol;
>     414         int ret = 0;
>     415 
>     416         list_for_each_entry(scontrol, &sdev->kcontrol_list, list) {
>     417                 if (scontrol->comp_id == swidget->comp_id) {
>     418                         switch (scontrol->info_type) {
>     419                         case SND_SOC_TPLG_CTL_VOLSW:
>     420                         case SND_SOC_TPLG_CTL_VOLSW_SX:
>     421                         case SND_SOC_TPLG_CTL_VOLSW_XR_SX:
>     422                                 ret = sof_ipc4_set_volume_data(sdev, swidget,
>     423                                                                scontrol, false);
>     424                                 break;
>     425                         case SND_SOC_TPLG_CTL_BYTES:
>     426                                 ret = sof_ipc4_set_get_bytes_data(sdev, scontrol,
>     427                                                                   true, false);
>     428                                 break;
> 
> This breaks out of the switch statement and not the loop.  So that means
> that it will continue through the loop and ret is reset.
> 
>     429                         default:
>     430                                 break;
>     431                         }
>     432                 }
>     433         }
>     434 
>     435         if (ret < 0)
> --> 436                 dev_err(sdev->dev, "kcontrol %d set up failed for widget %s\n",
>     437                         scontrol->comp_id, swidget->widget->name);
>                                 ^^^^^^^^^^^^^^^^^
> "scontrol" cannot be a valid pointer at this stage.  It is always an
> offset off the &sdev->kcontrol_list because of the above issue.

This is valid in a semantics sense and I will fix it.
In real life we have single control per swidget and this should have
been one step up.

> 
>     438 
>     439         return ret;
>     440 }
> 
> regards,
> dan carpenter

-- 
Péter

      reply	other threads:[~2023-03-21 13:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21  7:21 [bug report] ASoC: SOF: ipc4-control: Add support for bytes control get and put Dan Carpenter
2023-03-21 13:36 ` Péter Ujfalusi [this message]

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=6be945d2-40cb-46fb-67ba-ed3a19cddfa4@linux.intel.com \
    --to=peter.ujfalusi@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=error27@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.