]> 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)
commit6bfdb80123ce454fbf6bb0e4f559b0efc467b932
tree2f1e33cc53b862be579e1952d918bdeebbc8be26
parent6f3996ca4dfb1479be0798b9b038d13a2b45656f
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: 52e6dbea22cfe ("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