]> git.baikalelectronics.ru Git - kernel.git/commit
stm: ltdc: fix two incorrect NULL checks on list iterator
authorXiaomeng Tong <xiam0nd.tong@gmail.com>
Sun, 27 Mar 2022 05:53:55 +0000 (13:53 +0800)
committerPhilippe Cornu <philippe.cornu@foss.st.com>
Thu, 7 Apr 2022 08:26:59 +0000 (10:26 +0200)
commit22ba946ecaaa750dcc7eaf20c1fc38d0349f9ff0
tree2f1e33cc53b862be579e1952d918bdeebbc8be26
parentf0e727ca74c9968ff467e7bff6f6d6e0e0224419
stm: ltdc: fix two incorrect NULL checks on list iterator

The two bugs are here:
if (encoder) {
if (bridge && bridge->timings)

The list iterator value 'encoder/bridge' will *always* be set and
non-NULL by drm_for_each_encoder()/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 old variable 'encoder/bridge' as a dedicated pointer
to point to the found element.

Cc: stable@vger.kernel.org
Fixes: b822f3eaf316d ("drm/stm: Fix bus_flags handling")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Acked-by: Raphael Gallais-Pou <raphael.gallais-pou@foss.st.com>
Signed-off-by: Philippe Cornu <philippe.cornu@foss.st.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220327055355.3808-1-xiam0nd.tong@gmail.com
drivers/gpu/drm/stm/ltdc.c