lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADBw62qyyisDy2NkE29GYZkCi_O5Vgp+t1jeZtOkPsLV8UGFGQ@mail.gmail.com>
Date:   Fri, 1 Apr 2022 10:12:42 +0800
From:   Baolin Wang <baolin.wang7@...il.com>
To:     Jakob Koschel <jakobkoschel@...il.com>
Cc:     Codrin Ciubotariu <codrin.ciubotariu@...rochip.com>,
        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>,
        Cezary Rojewski <cezary.rojewski@...el.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>,
        Chunyan Zhang <zhang.lyra@...il.com>,
        Yang Yingliang <yangyingliang@...wei.com>,
        linux-arm-kernel@...ts.infradead.org,
        LKML <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>
Subject: Re: [PATCH 2/3] ASoC: sprd: remove check of list iterator against
 head past the loop body

On Fri, Apr 1, 2022 at 5:52 AM Jakob Koschel <jakobkoschel@...il.com> 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>

LGTM. Thanks.
Reviewed-by: Baolin Wang <baolin.wang@...ux.alibaba.com>

>  sound/soc/sprd/sprd-mcdt.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/sound/soc/sprd/sprd-mcdt.c b/sound/soc/sprd/sprd-mcdt.c
> index f6a55fa60c1b..6e27789a0df5 100644
> --- a/sound/soc/sprd/sprd-mcdt.c
> +++ b/sound/soc/sprd/sprd-mcdt.c
> @@ -866,20 +866,19 @@ EXPORT_SYMBOL_GPL(sprd_mcdt_chan_dma_disable);
>  struct sprd_mcdt_chan *sprd_mcdt_request_chan(u8 channel,
>                                               enum sprd_mcdt_channel_type type)
>  {
> -       struct sprd_mcdt_chan *temp;
> +       struct sprd_mcdt_chan *temp = NULL;
> +       struct sprd_mcdt_chan *iter;
>
>         mutex_lock(&sprd_mcdt_list_mutex);
>
> -       list_for_each_entry(temp, &sprd_mcdt_chan_list, list) {
> -               if (temp->type == type && temp->id == channel) {
> -                       list_del_init(&temp->list);
> +       list_for_each_entry(iter, &sprd_mcdt_chan_list, list) {
> +               if (iter->type == type && iter->id == channel) {
> +                       list_del_init(&iter->list);
> +                       temp = iter;
>                         break;
>                 }
>         }
>
> -       if (list_entry_is_head(temp, &sprd_mcdt_chan_list, list))
> -               temp = NULL;
> -
>         mutex_unlock(&sprd_mcdt_list_mutex);
>
>         return temp;
> --
> 2.25.1
>


-- 
Baolin Wang

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ