From: Xiaomeng Tong <xiam0nd.tong@gmail.com>
To: emil.l.velikov@gmail.com
Cc: airlied@linux.ie, bskeggs@redhat.com, daniel@ffwll.ch,
dri-devel@lists.freedesktop.org, kherbst@redhat.com,
linux-kernel@vger.kernel.org, lyude@redhat.com,
nouveau@lists.freedesktop.org, stable@vger.kernel.org,
xiam0nd.tong@gmail.com, yangyingliang@huawei.com
Subject: Re: [PATCH] dispnv50: atom: fix an incorrect NULL check on list iterator
Date: Mon, 28 Mar 2022 10:09:02 +0800 [thread overview]
Message-ID: <20220328020902.19369-1-xiam0nd.tong@gmail.com> (raw)
In-Reply-To: <CACvgo50pK3rr5UH_FyfR1pADmPRjEawi43cAecoaz7nM5AFgBg@mail.gmail.com>
on Sun, 27 Mar 2022 16:59:28 +0100, Emil Velikov wrote:
> On Sun, 27 Mar 2022 at 08:39, Xiaomeng Tong <xiam0nd.tong@gmail.com> wrote:
> >
> > The bug is here:
> > return encoder;
> >
> > The list iterator value 'encoder' will *always* be set and non-NULL
> > by drm_for_each_encoder_mask(), so it is incorrect to assume that the
> > iterator value will be NULL if the list is empty or no element found.
> > Otherwise it will bypass some NULL checks and lead to invalid memory
> > access passing the check.
> >
> > To fix this bug, just return 'encoder' when found, otherwise return
> > NULL.
> >
>
> Isn't this covered by the upcoming list* iterator rework [1] or is
> this another iterator glitch?
Actually, it is a part of the upcoming work.
> IMHO we should be looking at fixing the implementation and not the
> hundreds of users through the kernel.
>
> HTH
> -Emil
> [1] https://lwn.net/Articles/887097/
Yes, you are right. This has also been taken into account by the upcoming
list iterator rework to avoid a lot uesr' changes as much as possible.
However, this patch is fixing a potential bug caused by incorrect use of
list iterator outside the loop, which can not be fixed by the implementation
itself.
--
Xiaomeng Tong
next prev parent reply other threads:[~2022-03-28 2:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-27 7:39 Xiaomeng Tong
2022-03-27 15:59 ` Emil Velikov
2022-03-28 2:09 ` Xiaomeng Tong [this message]
2022-03-29 10:59 ` Emil Velikov
2022-03-28 21:20 ` Lyude Paul
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=20220328020902.19369-1-xiam0nd.tong@gmail.com \
--to=xiam0nd.tong@gmail.com \
--cc=airlied@linux.ie \
--cc=bskeggs@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=kherbst@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lyude@redhat.com \
--cc=nouveau@lists.freedesktop.org \
--cc=stable@vger.kernel.org \
--cc=yangyingliang@huawei.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
all inboxes | Powered by JetHome®