[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c69ee5e5-213f-389c-9d22-69addddf2aca@intel.com>
Date: Fri, 1 Apr 2022 09:00:09 +0200
From: Cezary Rojewski <cezary.rojewski@...el.com>
To: Jakob Koschel <jakobkoschel@...il.com>
CC: Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Nicolas Ferre <nicolas.ferre@...rochip.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Claudiu Beznea <claudiu.beznea@...rochip.com>,
Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
Liam Girdwood <liam.r.girdwood@...ux.intel.com>,
Jie Yang <yang.jie@...ux.intel.com>,
"Mark Brown" <broonie@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
Orson Zhai <orsonzhai@...il.com>,
Baolin Wang <baolin.wang7@...il.com>,
Chunyan Zhang <zhang.lyra@...il.com>,
"Yang Yingliang" <yangyingliang@...wei.com>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <alsa-devel@...a-project.org>,
Mike Rapoport <rppt@...nel.org>,
Brian Johannesmeyer <bjohannesmeyer@...il.com>,
"Cristiano Giuffrida" <c.giuffrida@...nl>,
"Bos, H.J." <h.j.bos@...nl>,
Codrin Ciubotariu <codrin.ciubotariu@...rochip.com>
Subject: Re: [PATCH 1/3] ASoC: Intel: catpt: remove check of list iterator
against head past the loop body
On 2022-03-31 11:50 PM, Jakob Koschel wrote:
> When list_for_each_entry() completes the iteration over the whole list
> without breaking the loop, the iterator value will be a bogus pointer
> computed based on the head element.
>
> While it is safe to use the pointer to determine if it was computed
> based on the head element, either with list_entry_is_head() or
> &pos->member == head, using the iterator variable after the loop should
> be avoided.
>
> In preparation to limiting the scope of a list iterator to the list
> traversal loop, use a dedicated pointer to point to the found element [1].
>
> Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1]
> Signed-off-by: Jakob Koschel <jakobkoschel@...il.com>
Thank you for taking time and updating catpt-driver along the way.
Acked-by: Cezary Rojewski <cezary.rojewski@...el.com>
> ---
> sound/soc/intel/catpt/pcm.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/sound/soc/intel/catpt/pcm.c b/sound/soc/intel/catpt/pcm.c
> index a26000cd5ceb..b103b2d4026e 100644
> --- a/sound/soc/intel/catpt/pcm.c
> +++ b/sound/soc/intel/catpt/pcm.c
> @@ -330,7 +330,8 @@ static int catpt_dai_apply_usettings(struct snd_soc_dai *dai,
> struct catpt_stream_runtime *stream)
> {
> struct snd_soc_component *component = dai->component;
> - struct snd_kcontrol *pos;
> + struct snd_kcontrol *pos = NULL;
> + struct snd_kcontrol *iter;
> struct catpt_dev *cdev = dev_get_drvdata(dai->dev);
> const char *name;
> int ret;
> @@ -354,12 +355,14 @@ static int catpt_dai_apply_usettings(struct snd_soc_dai *dai,
> return 0;
> }
>
> - list_for_each_entry(pos, &component->card->snd_card->controls, list) {
> - if (pos->private_data == component &&
> - !strncmp(name, pos->id.name, sizeof(pos->id.name)))
> + list_for_each_entry(iter, &component->card->snd_card->controls, list) {
> + if (iter->private_data == component &&
> + !strncmp(name, iter->id.name, sizeof(iter->id.name))) {
> + pos = iter;
> break;
> + }
> }
> - if (list_entry_is_head(pos, &component->card->snd_card->controls, list))
> + if (!pos)
> return -ENOENT;
>
> if (stream->template->type != CATPT_STRM_TYPE_LOOPBACK)
>
> base-commit: f82da161ea75dc4db21b2499e4b1facd36dab275
Powered by blists - more mailing lists