Re: [PATCH] stm: ltdc: fix two incorrect NULL checks on list iterator

From: Philippe CORNU
Date: Thu Apr 07 2022 - 05:02:21 EST




On 3/28/22 14:37, Raphael Gallais-Pou wrote:
Hello Xiaomeng

On 3/27/22 07:53, Xiaomeng Tong wrote:
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@xxxxxxxxxxxxxxx
Fixes: 99e360442f223 ("drm/stm: Fix bus_flags handling")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx>
---
drivers/gpu/drm/stm/ltdc.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)


Thanks for your fix

Acked-by: Raphael Gallais-Pou <raphael.gallais-pou@xxxxxxxxxxx>


Raphaël Gallais-Pou


Applied on drm-misc-next.
Many thanks for your patch,
Philippe :-)