This is a note to let you know that I've just added the patch titled tilcdc: tilcdc_external: fix an incorrect NULL check on list iterator to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: tilcdc-tilcdc_external-fix-an-incorrect-null-check-on-list-iterator.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 8b917cbe38e9b0d002492477a9fc2bfee2412ce4 Mon Sep 17 00:00:00 2001 From: Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx> Date: Sun, 27 Mar 2022 14:15:16 +0800 Subject: tilcdc: tilcdc_external: fix an incorrect NULL check on list iterator From: Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx> commit 8b917cbe38e9b0d002492477a9fc2bfee2412ce4 upstream. 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@xxxxxxxxxxxxxxx Fixes: ec9eab097a500 ("drm/tilcdc: Add drm bridge support for attaching drm bridge drivers") Signed-off-by: Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx> Reviewed-by: Jyri Sarha <jyri.sarha@xxxxxx> Tested-by: Jyri Sarha <jyri.sarha@xxxxxx> Signed-off-by: Jyri Sarha <jyri.sarha@xxxxxx> Link: https://patchwork.freedesktop.org/patch/msgid/20220327061516.5076-1-xiam0nd.tong@xxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/tilcdc/tilcdc_external.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c @@ -60,11 +60,13 @@ struct drm_connector *tilcdc_encoder_fin int tilcdc_add_component_encoder(struct drm_device *ddev) { struct tilcdc_drm_private *priv = ddev->dev_private; - struct drm_encoder *encoder; + struct drm_encoder *encoder = NULL, *iter; - list_for_each_entry(encoder, &ddev->mode_config.encoder_list, head) - if (encoder->possible_crtcs & (1 << priv->crtc->index)) + list_for_each_entry(iter, &ddev->mode_config.encoder_list, head) + if (iter->possible_crtcs & (1 << priv->crtc->index)) { + encoder = iter; break; + } if (!encoder) { dev_err(ddev->dev, "%s: No suitable encoder found\n", __func__); Patches currently in stable-queue which might be from xiam0nd.tong@xxxxxxxxx are queue-5.15/md-fix-an-incorrect-null-check-in-does_sb_need_changing.patch queue-5.15/stm-ltdc-fix-two-incorrect-null-checks-on-list-iterator.patch queue-5.15/scsi-dc395x-fix-a-missing-check-on-list-iterator.patch queue-5.15/iommu-msm-fix-an-incorrect-null-check-on-list-iterator.patch queue-5.15/carl9170-tx-fix-an-incorrect-use-of-list-iterator.patch queue-5.15/tilcdc-tilcdc_external-fix-an-incorrect-null-check-on-list-iterator.patch queue-5.15/gma500-fix-an-incorrect-null-check-on-list-iterator.patch queue-5.15/drm-nouveau-clk-fix-an-incorrect-null-check-on-list-iterator.patch queue-5.15/media-uvcvideo-fix-missing-check-to-determine-if-ele.patch queue-5.15/md-fix-an-incorrect-null-check-in-md_reload_sb.patch queue-5.15/drm-nouveau-kms-nv50-atom-fix-an-incorrect-null-check-on-list-iterator.patch