tilcdc: tilcdc_external: fix an incorrect NULL check on list iterator
authorXiaomeng Tong <xiam0nd.tong@gmail.com>
Sun, 27 Mar 2022 06:15:16 +0000 (14:15 +0800)
committerJyri Sarha <jyri.sarha@iki.fi>
Tue, 29 Mar 2022 10:58:58 +0000 (13:58 +0300)
commit8b917cbe38e9b0d002492477a9fc2bfee2412ce4
tree3006370343f5fb7cae677ba80fbe1e412a95407d
parentbdef417d84536715145f6dc9cc3275c46f26295a
tilcdc: tilcdc_external: fix an incorrect NULL check on list iterator

The bug is here:
if (!encoder) {

The list iterator value 'encoder' will *always* be set and non-NULL
by list_for_each_entry(), so it is incorrect to assume that the
iterator value will be NULL if the list is empty or no element
is found.

To fix the bug, use a new variable 'iter' as the list iterator,
while use the original variable 'encoder' as a dedicated pointer
to point to the found element.

Cc: stable@vger.kernel.org
Fixes: ec9eab097a500 ("drm/tilcdc: Add drm bridge support for attaching drm bridge drivers")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Reviewed-by: Jyri Sarha <jyri.sarha@iki.fi>
Tested-by: Jyri Sarha <jyri.sarha@iki.fi>
Signed-off-by: Jyri Sarha <jyri.sarha@iki.fi>
Link: https://patchwork.freedesktop.org/patch/msgid/20220327061516.5076-1-xiam0nd.tong@gmail.com
drivers/gpu/drm/tilcdc/tilcdc_external.c