]> git.baikalelectronics.ru Git - kernel.git/commit
drm/nouveau/kms/nv50-: atom: fix an incorrect NULL check on list iterator
authorXiaomeng Tong <xiam0nd.tong@gmail.com>
Sun, 27 Mar 2022 07:39:25 +0000 (15:39 +0800)
committerLyude Paul <lyude@redhat.com>
Mon, 28 Mar 2022 21:31:27 +0000 (17:31 -0400)
commitaf38f5b3b2ab141452edd3c6b2ed8f985c234a0d
treeb3e460a7b3a1a4411b3b73afe631855b08ad9127
parent2e2996728f00aeaaa6d70bd9da46cb142a6db278
drm/nouveau/kms/nv50-: atom: fix an incorrect NULL check on list iterator

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.

Cc: stable@vger.kernel.org
Fixes: 482f7ba66f935 ("drm/nouveau/kms/nvd9-: Add CRC support")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
[Changed commit title]
Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220327073925.11121-1-xiam0nd.tong@gmail.com
drivers/gpu/drm/nouveau/dispnv50/atom.h
drivers/gpu/drm/nouveau/dispnv50/crc.c